diff --git a/app.py b/app.py index e78d937e..046d105f 100644 --- a/app.py +++ b/app.py @@ -18,22 +18,22 @@ from modules.configuration import APP_CONFIG def initLogging(): # Get log level from config (default to INFO if not found) - logLevelName = APP_CONFIG.get("Logging_LOG_LEVEL", "WARNING") + logLevelName = APP_CONFIG.get("APP_LOGGING_LOG_LEVEL", "WARNING") logLevel = getattr(logging, logLevelName) # Configure handlers based on config handlers = [] # Add console handler if enabled - if APP_CONFIG.get("Logging_CONSOLE_ENABLED", True): + if APP_CONFIG.get("APP_LOGGING_CONSOLE_ENABLED", True): consoleHandler = logging.StreamHandler() handlers.append(consoleHandler) # Add file handler if enabled - if APP_CONFIG.get("Logging_FILE_ENABLED", True): - logFile = APP_CONFIG.get("Logging_LOG_FILE", "app.log") - rotationSize = int(APP_CONFIG.get("Logging_ROTATION_SIZE", 10485760)) # Default: 10MB - backupCount = int(APP_CONFIG.get("Logging_BACKUP_COUNT", 5)) + if APP_CONFIG.get("APP_LOGGING_FILE_ENABLED", True): + logFile = APP_CONFIG.get("APP_LOGGING_LOG_FILE", "app.log") + rotationSize = int(APP_CONFIG.get("APP_LOGGING_ROTATION_SIZE", 10485760)) # Default: 10MB + backupCount = int(APP_CONFIG.get("APP_LOGGING_BACKUP_COUNT", 5)) fileHandler = RotatingFileHandler( logFile, @@ -45,8 +45,8 @@ def initLogging(): # Configure the logger logging.basicConfig( level=logLevel, - format=APP_CONFIG.get("Logging_FORMAT", "%(asctime)s - %(levelname)s - %(name)s - %(message)s"), - datefmt=APP_CONFIG.get("Logging_DATE_FORMAT", "%Y-%m-%d %H:%M:%S"), + format=APP_CONFIG.get("APP_LOGGING_FORMAT", "%(asctime)s - %(levelname)s - %(name)s - %(message)s"), + datefmt=APP_CONFIG.get("APP_LOGGING_DATE_FORMAT", "%Y-%m-%d %H:%M:%S"), handlers=handlers ) diff --git a/config.ini b/config.ini index 0815e76a..8f803896 100644 --- a/config.ini +++ b/config.ini @@ -23,16 +23,6 @@ Connector_AiAnthropic_MAX_TOKENS = 2000 File_Management_MAX_UPLOAD_SIZE_MB = 50 File_Management_CLEANUP_INTERVAL = 240 -# Logging configuration -Logging_LOG_LEVEL = DEBUG -Logging_LOG_FILE = poweron.log -Logging_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s -Logging_DATE_FORMAT = %Y-%m-%d %H:%M:%S -Logging_CONSOLE_ENABLED = True -Logging_FILE_ENABLED = True -Logging_ROTATION_SIZE = 10485760 -Logging_BACKUP_COUNT = 5 - # Security configuration (for future use) Security_PASSWORD_MIN_LENGTH = 8 Security_PASSWORD_REQUIRE_UPPERCASE = True diff --git a/env_dev.env b/env_dev.env index 0cd4ccc0..5b56945b 100644 --- a/env_dev.env +++ b/env_dev.env @@ -23,3 +23,13 @@ APP_TOKEN_EXPIRY=300 # CORS Configuration APP_ALLOWED_ORIGINS=http://localhost:8080,https://playground.poweron-center.net + +# Logging configuration +APP_LOGGING_LOG_LEVEL = DEBUG +APP_LOGGING_LOG_FILE = poweron.log +APP_LOGGING_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s +APP_LOGGING_DATE_FORMAT = %Y-%m-%d %H:%M:%S +APP_LOGGING_CONSOLE_ENABLED = True +APP_LOGGING_FILE_ENABLED = True +APP_LOGGING_ROTATION_SIZE = 10485760 +APP_LOGGING_BACKUP_COUNT = 5 \ No newline at end of file diff --git a/env_prod.env b/env_prod.env index 38a565c3..2dc3727d 100644 --- a/env_prod.env +++ b/env_prod.env @@ -23,3 +23,13 @@ APP_TOKEN_EXPIRY=300 # CORS Configuration APP_ALLOWED_ORIGINS=http://localhost:8080,https://playground.poweron-center.net + +# Logging configuration +APP_LOGGING_LOG_LEVEL = DEBUG +APP_LOGGING_LOG_FILE = /home/poweron.log +APP_LOGGING_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s +APP_LOGGING_DATE_FORMAT = %Y-%m-%d %H:%M:%S +APP_LOGGING_CONSOLE_ENABLED = True +APP_LOGGING_FILE_ENABLED = True +APP_LOGGING_ROTATION_SIZE = 10485760 +APP_LOGGING_BACKUP_COUNT = 5 \ No newline at end of file