Spaces:
Sleeping
Sleeping
File size: 974 Bytes
82fa936 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """
Central Logging Configuration
"""
import logging
import sys
from config import LOGGING_ENABLED
def setup_logging():
"""
Configure logging based on LOGGING_ENABLED flag in config.
If enabled, logs to both file (smurf_village.log) and console.
If disabled, sets logging level to CRITICAL to suppress all logs.
"""
if LOGGING_ENABLED:
# Configure logging to file and console
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('smurf_village.log'),
logging.StreamHandler(sys.stdout)
],
force=True # Override any existing configuration
)
else:
# Disable logging by setting level to CRITICAL
logging.basicConfig(
level=logging.CRITICAL,
handlers=[logging.NullHandler()],
force=True
)
|