Global Configuration#
Overview#
Module Constants#
- academic_metrics.configs.global_config.LOG_TO_CONSOLE: bool#
Controls whether log messages are displayed in the console. Default is True.
Classes#
Color Formatter#
- class academic_metrics.configs.global_config.ColorFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]#
Bases:
FormatterCustom formatter that adds colors to log levels
- Public Methods
format: Format the log record with colors.
-
COLOR_MAP:
Dict[str,str] = {'CRITICAL': '\x1b[41m', 'DEBUG': '\x1b[36m', 'ERROR': '\x1b[31m', 'INFO': '\x1b[32m', 'RESET': '\x1b[0m', 'WARNING': '\x1b[33m'}#
- format(record)[source]#
Format the log record with colors
- Parameters:
record (logging.LogRecord) – The log record to format.
- Returns:
The formatted log record with colors.
- Return type:
Functions#
Configure Logging#
- academic_metrics.configs.global_config.configure_logging(module_name, log_file_name=None, log_level=30, force=False)[source]#
Configure a logger for a specific module.
Configures logging for a module if not already configured. Acts as a singleton per module_name.
- Parameters:
module_name (str) – The name of the module to configure logging for.
module. (- This should be passed in as the __name__ variable of the)
log_file_name (str) – The name of the log file to use for the module.
extension. (- This should be a valid file name with no file)
module (- It should only be the file name desired for that)
path. (not the full)
log_level (int) – The log level to use for the module.
level. (- This should be a valid python logging log)
force (bool) – Whether to force the creation of a new logger instance.
False (- If a logger instance for the module already exists and force is)
returned. (the existing instance will be)
True (- If a logger instance for the module already exists and force is)
created. (a new instance will be)
- Returns:
The configured logger for the module.
- Return type:
Set Log to Console#
- academic_metrics.configs.global_config.set_log_to_console(value)[source]#
Set the global LOG_TO_CONSOLE variable.
Void function which sets the global LOG_TO_CONSOLE to the provided boolean value or issues a warning and leaves the current value unchanged if the provided value is not a boolean.
Warning
If the value is not a boolean, a warning is issued and the current value remains unchanged.