fixed logging

This commit is contained in:
TylerCG 2025-05-12 16:43:12 -04:00
parent c1b7e0e2ad
commit 6e005f053e
2 changed files with 5 additions and 12 deletions

View File

@ -2,14 +2,7 @@ import os, yt_dlp, json, requests, re, logging
from bs4 import BeautifulSoup
from urllib.parse import urlsplit
# Setup logging
logging.basicConfig(
filename='/data/logs/syllabus.log',
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger("download_logger")
logger = logging.getLogger("syllabus")
# Define the hook function
def my_hook(d):

View File

@ -12,8 +12,8 @@ from logging.handlers import TimedRotatingFileHandler
os.makedirs("/data/logs", exist_ok=True)
# Setup timed rotating logger
log_path = "/data/logs/syllabus.log"
logger = logging.getLogger("main_logger")
# log_path = "/data/logs/syllabus.log"
logger = logging.getLogger("syllabus")
logger.setLevel(logging.DEBUG)
# Remove any default handlers
@ -21,7 +21,7 @@ logger.handlers = []
# Set up TimedRotatingFileHandler
handler = TimedRotatingFileHandler(
filename=log_path,
filename="/data/logs/syllabus.log",
when="midnight", # Rotate at midnight
interval=1, # Every 1 day
backupCount=30, # Keep last 7 logs
@ -29,7 +29,7 @@ handler = TimedRotatingFileHandler(
utc=False # Use UTC for time reference
)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)