Skip to content

Commit

Permalink
logging file issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosalmi committed Feb 1, 2025
1 parent 7e5a850 commit c2842e6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions logging_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import logging
import os
from config import LOG_FILE # ...existing imports...

def setup_logging():
# ...existing code...
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# Clear any existing handlers
logger.handlers = []

# Console handler (unchanged)
console_handler = logging.StreamHandler()
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
console_handler.setFormatter(console_formatter)
logger.addHandler(console_handler)

# New file handler for LOG_FILE
file_handler = logging.FileHandler(LOG_FILE)
file_formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
file_handler.setFormatter(file_formatter)
logger.addHandler(file_handler)

logging.info(f"Logging is set up. Log file: {LOG_FILE}")

0 comments on commit c2842e6

Please sign in to comment.