import logging import os from datetime import datetime # Use a safe writable directory like /tmp/logs for the log files in container environments LOG_DIR = os.path.join("/tmp", "logs") os.makedirs(LOG_DIR, exist_ok=True) # Ensure the log directory is created LOG_FILE = f"{datetime.now().strftime('%m_%d_%Y_%H_%M_%S')}.log" LOG_FILE_PATH = os.path.join(LOG_DIR, LOG_FILE) logging.basicConfig( filename=LOG_FILE_PATH, format="[ %(asctime)s ] %(lineno)d %(name)s - %(levelname)s - %(message)s", level=logging.INFO ) logging.info("Logging setup complete. Log file created at: %s", LOG_FILE_PATH)