# FlightMonitor/data/logging_config.py

import logging

# --- Logging Configuration ---

# Default logging level for the root logger.
# Valid levels: logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL
DEFAULT_ROOT_LOG_LEVEL = logging.INFO

# Specific logging levels for named loggers (modules or custom names).
# This dictionary allows granular control over logging verbosity.
# Format: {"logger_name": logging.LEVEL, ...}
# Examples:
# - "flightmonitor.data.opensky_live_adapter": logging.DEBUG # Show all messages from the adapter
# - "flightmonitor.map.map_tile_manager": logging.WARNING # Only show warnings/errors from map tile manager
# - "": logging.INFO # The empty string "" refers to the root logger
SPECIFIC_LOGGER_LEVELS = {
    # Aggiungi i logger dei moduli che vuoi debuggare a livelli specifici qui.
    # Esempio:
    # "flightmonitor.map.map_canvas_manager": logging.DEBUG,
    # "flightmonitor.data.opensky_live_adapter": logging.DEBUG,
}

# Format string for log messages.
# See Python's logging documentation for format codes.
LOG_FORMAT = "%(asctime)s [%(levelname)-8s] %(name)-20s : %(message)s"

# Format string for the date/time in log messages.
LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"

# Colors for different log levels in the GUI log widget.
# These should be valid Tkinter color names or hex codes.
LOG_LEVEL_COLORS = {
    logging.DEBUG: "RoyalBlue1",
    logging.INFO: "black",
    logging.WARNING: "dark orange",
    logging.ERROR: "red2",
    logging.CRITICAL: "red4",
}

# Interval for polling the log queue in the TkinterTextHandler (in milliseconds).
LOG_QUEUE_POLL_INTERVAL_MS = 100

# Flag to enable or disable console logging.
ENABLE_CONSOLE_LOGGING = True

# Flag to enable or disable file logging (Not implemented in logger.py yet, but placeholder).
ENABLE_FILE_LOGGING = False
LOG_FILE_PATH = "flight_monitor.log"
LOG_FILE_MAX_BYTES = 10 * 1024 * 1024  # 10 MB
LOG_FILE_BACKUP_COUNT = 5

# --- Consolidated Logging Configuration Dictionary ---
# This dictionary will be passed to the logger setup function.
LOGGING_CONFIG = {
    "default_root_level": DEFAULT_ROOT_LOG_LEVEL,
    "specific_levels": SPECIFIC_LOGGER_LEVELS,
    "format": LOG_FORMAT,
    "date_format": LOG_DATE_FORMAT,
    "colors": LOG_LEVEL_COLORS,
    "queue_poll_interval_ms": LOG_QUEUE_POLL_INTERVAL_MS,
    "enable_console": ENABLE_CONSOLE_LOGGING,
    "enable_file": ENABLE_FILE_LOGGING,
    "file_path": LOG_FILE_PATH,
    "file_max_bytes": LOG_FILE_MAX_BYTES,
    "file_backup_count": LOG_FILE_BACKUP_COUNT,
}
