Spaces:
Runtime error
Runtime error
File size: 610 Bytes
69bc517 c152ba9 69bc517 c152ba9 69bc517 c152ba9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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)
|