eelib.utils.logging_helpers
Logging helper with custom format and functions to set logger.
Module Contents
Classes
CustomFormatter with different colors for logging levels. |
Functions
Function to remove existing loggers. |
|
|
Set console output logger. |
|
Set file logger. |
Attributes
- LOGGING_FORMAT = '%(asctime)s | %(levelname)-9s| %(threadName)s | %(name)s:%(lineno)d - %(message)s'
- class CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)
Bases:
logging.Formatter
CustomFormatter with different colors for logging levels. Specialization of logging.Formatter.
- grey = '\x1b[38;20m'
- yellow = '\x1b[33;20m'
- red = '\x1b[31;20m'
- bold_red = '\x1b[31;1m'
- reset = '\x1b[0m'
- format_str
- FORMATS
- format(record)
Overrides format method.
- Parameters:
record (_type_) – record to log.
- Returns:
Formatted log string.
- Return type:
str
- clear_logger()
Function to remove existing loggers.
- set_console_logger(level: int = logging.DEBUG)
Set console output logger. All messages will be printed to StdOut.
- Parameters:
level (int) – Logging level. Defaults to logging.DEBUG.
- set_file_logger(level: int = logging.DEBUG, filename: str = 'eELib.log')
Set file logger. All messages will be written to the file with given filename.
- Parameters:
level (int) – Logging level. Defaults to logging.DEBUG.
filename (str) – Logfile filename. Defaults to “eELib.log”.