rex.utilities.loggers.LoggingAttributes

class LoggingAttributes[source]

Bases: object

Class to store and pass logging attributes to modules

Methods

clear()

Clear all log handlers

init_loggers(loggers)

Extract logger attributes and initialize logger

set_logger(logger_name[, stream, log_level, ...])

Setup logging instance with given name and attributes

Attributes

logger_names

Logger names

loggers

Available loggers

property loggers

Available loggers

Returns:

dict

property logger_names

Logger names

Returns:

list

set_logger(logger_name, stream=True, log_level='INFO', log_file=None, log_format='%(levelname)s - %(asctime)s [%(filename)s:%(lineno)d] : %(message)s')[source]

Setup logging instance with given name and attributes

Parameters:
  • logger_name (str) – Name of logger

  • stream (bool, optional) – Add a StreamHandler along with FileHandler, by default True

  • log_level (str, optional) – Level of logging to capture, must be key in LOG_LEVEL. If multiple handlers/log_files are requested in a single call of this function, the specified logging level will be applied to all requested handlers, by default “INFO”

  • log_file (str | list, optional) – Path to file to use for logging, if None use a StreamHandler list of multiple handlers is permitted, by default None

  • log_format (str, optional) – Format for loggings, by default FORMAT

Returns:

logger (logging.logger) – instance of logger for given name, with given level and added handlers(s)

init_loggers(loggers)[source]

Extract logger attributes and initialize logger

Parameters:

loggers (str | list) – Logger names to initialize

clear()[source]

Clear all log handlers