marmot.utils.loggersetup.SetupLogger#
- class SetupLogger(logger_type: str, log_directory: pathlib.Path = WindowsPath('C:/Users/dlevie/Documents/Marmot/logs'), log_suffix: Optional[str] = None, **kwargs)[source]#
Bases:
object
Sets up the python logger.
This class handles the following.
Configures logger from LOG_CONFIG_FILE file or DEFAULT_LOG_CONFIG.
Handles rollover of log file on each instantiation.
Sets log_directory.
Append optional suffix to the end of the log file name
Optional suffix is useful when running multiple processes in parallel to allow logging to separate files.
- Parameters
Methods
Attributes
Default log config if LOG_CONFIG_FILE cannot be found
Name of default logging config file located in utils package
- LOG_CONFIG_FILE: str = 'marmot_logging_config.yml'#
Name of default logging config file located in utils package
- DEFAULT_LOG_CONFIG: dict = {'formatters': {'info_format': {'datefmt': '%Y-%m-%d %H:%M:%S', 'format': '%(asctime)s:%(levelname)-8s- %(message)s'}, 'warning_format': {'datefmt': '%Y-%m-%d %H:%M:%S', 'format': '%(asctime)s:%(levelname)s:%(module)s.%(funcName)s - %(message)s'}}, 'handlers': {'console': {'class': 'logging.StreamHandler', 'level': 'INFO', 'stream': 'ext://sys.stdout'}, 'info_handler': {'backupCount': 3, 'class': 'logging.handlers.RotatingFileHandler', 'encoding': 'utf8', 'filename': '{}/Log_{}{}.log', 'formatter': 'info_format', 'level': 'INFO', 'mode': 'a'}, 'warning_handler': {'backupCount': 3, 'class': 'logging.handlers.RotatingFileHandler', 'encoding': 'utf8', 'filename': '{}/WARNINGS_{}{}.log', 'formatter': 'warning_format', 'level': 'WARNING', 'mode': 'a'}}, 'loggers': {'formatter': {'handlers': ['console', 'warning_handler', 'info_handler'], 'level': 'INFO', 'propagate': True}, 'plotter': {'handlers': ['console', 'warning_handler', 'info_handler'], 'level': 'INFO', 'propagate': True}, 'root': {'handlers': ['console'], 'level': 'DEBUG'}}, 'version': 1}#
Default log config if LOG_CONFIG_FILE cannot be found