33 lines
780 B
Python
33 lines
780 B
Python
"""Logging configuration for the application."""
|
|
|
|
import logging
|
|
from logging.handlers import TimedRotatingFileHandler
|
|
import config
|
|
|
|
|
|
def setup_logger() -> logging.Logger:
|
|
"""Configure and return the application logger."""
|
|
config.ensure_directories()
|
|
|
|
logger = logging.getLogger("syllabus")
|
|
logger.setLevel(config.LOG_LEVEL)
|
|
|
|
# Remove any default handlers
|
|
logger.handlers = []
|
|
|
|
# Set up TimedRotatingFileHandler
|
|
handler = TimedRotatingFileHandler(
|
|
filename=str(config.LOG_FILE),
|
|
when="midnight",
|
|
interval=30,
|
|
backupCount=12,
|
|
encoding="utf-8",
|
|
utc=False
|
|
)
|
|
|
|
formatter = logging.Formatter(config.LOG_FORMAT)
|
|
handler.setFormatter(formatter)
|
|
logger.addHandler(handler)
|
|
|
|
return logger
|