akkudoktoreos.core.logging.get_logger

akkudoktoreos.core.logging.get_logger(name: str, log_file: str | None = None, logging_level: str | None = None, max_bytes: int = 5000000, backup_count: int = 5) Logger

Creates and configures a logger with a given name.

The logger supports logging to both the console and an optional log file. File logging is handled by a rotating file handler to prevent excessive log file size.

Parameters:
  • name (str) – The name of the logger, typically __name__ from the calling module.

  • log_file (Optional[str]) – Path to the log file for file logging. If None, no file logging is done.

  • logging_level (Optional[str]) – Logging level (e.g., “INFO”, “DEBUG”). Defaults to “INFO”.

  • max_bytes (int) – Maximum size in bytes for log file before rotation. Defaults to 5 MB.

  • backup_count (int) – Number of backup log files to keep. Defaults to 5.

Returns:

Configured logger instance.

Return type:

logging.Logger

Example

logger = get_logger(__name__, log_file=”app.log”, logging_level=”DEBUG”) logger.info(“Application started”)