chore: Update logging format and add debug messages

- Changed the logging format in `trackbert.py` to include date, time, and message level.
- Added debug messages to show the number of events retrieved for a tracking number.
This commit is contained in:
Kumi 2023-08-18 09:17:05 +02:00
parent 9802e28454
commit 018cccb6a1
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -7,8 +7,12 @@ import subprocess
import argparse
import logging
logging.basicConfig(level=logging.DEBUG)
# Print date and time and level with message
logging.basicConfig(
format="%(asctime)s %(levelname)s: %(message)s",
level=logging.DEBUG,
datefmt="%Y-%m-%d %H:%M:%S",
)
def notify(title, message):
logging.debug(f"Sending notification: {title} - {message}")
@ -117,7 +121,7 @@ def start_loop(db, api: KeyDelivery):
all_events = api.realtime(carrier, tracking_number)
try:
all_events["data"]["items"]
logging.debug(f"Got events for {tracking_number}: {len(all_events)}")
except KeyError:
print(f"Error getting events for {tracking_number}: {all_events}")
continue