mpas_tools.logging.LoggingContext

class mpas_tools.logging.LoggingContext(name, logger=None, log_filename=None)[source]

A context manager for creating a logger or using an existing logger

Variables

~LoggingContext.logger (logging.Logger) – A logger that sends output to a log file or stdout/stderr

__init__(name, logger=None, log_filename=None)[source]

If logger is None, create a new logger either to a log file or stdout/stderr. If logger is anything else, just set the logger attribute

Parameters
  • name (str) – A unique name for the logger (e.g. __name__ of the calling module)

  • logger (logging.Logger, optional) – An existing logger that sends output to a log file or stdout/stderr to be used in this context

  • log_filename (str, optional) – The name of a file where output should be written. If none is supplied, output goes to stdout/stderr

Methods

__init__(name[, logger, log_filename])

If logger is None, create a new logger either to a log file or stdout/stderr.