core.common package
Submodules
core.common.logger module
Module CustomLogger
This module provides a class for logging management.
- Classes:
CustomLogger – Manages the creation and configuration of loggers with file and stream handlers.
- Usage:
logger = CustomLogger(“example_logger”, “path/to/logfile.log”).get_logger() logger.info(“This is an info message”)
- class core.common.logger.CustomLogger(name: str, log_file: str, level: int = 10)[source]
Bases:
object
A class to create and configure custom loggers with file and stream handlers.
- _instances
A dictionary to maintain singleton logger instances.
- Type:
dict
- __new__(cls, name
str, log_file: str, level: int = logging.DEBUG) – Creates a new instance of CustomLogger if it does not already exist.
- __init__(self, name
str, log_file: str, level: int = logging.DEBUG) – Initializes the logger with the specified name and log file.
- get_logger(self) -- Returns the logger instance.
Initializes the logger with the specified name and log file.
- Parameters:
name (str) – The name of the logger.
log_file (str) – The path to the log file.
level (int) – The logging level. Default is logging.DEBUG.