log_config
- jwst.associations.lib.log_config.log_config(name=None, user_name=None, logger_config=None, config=None, merge=True)[source]
Set up logging with defaults.
logging.config.dictConfigis used with optional default configuration dict.- Parameters:
- namestr
The name of the logger to instantiate. If None, the root logger will be modified.
- user_namestr
User-understandable name. If not specified, it will be the same as
name.- logger_configdict
The dictionary to use to set up the logger. This is used as the value to the key of
name.- configdict
User-specified logging configuration.
- mergebool
Merge the user-specified configuration in with base configuration. If
False, just use the user-specified one.
- Returns:
logging.LoggerThe logger instance.
Notes
Internally, the logging configuration is placed into
logging.config.dictConfig.base_configdefines a set of handlers, formatters, and filters that separate out the different levels as follows:defaultHandles
logging.WARNINGand above.debugHandles
logging.DEBUGexclusively.infoHandles
logging.INFOexclusively.
Given the defaults, a logger is created with the given
name, with the levels as described above.To make modifications:
The pair of parameters
nameandlogger_configtogether make up the dictionary that is the value to the top-level keyloggers.The parameter
configdefines the rest of the top-level keys for configuration dictionary.When the parameter
mergeisTrue, the following happens:For the
formattersdictionary, the dictionary for the keynameis created by first creating the default dictionary, and then doing andict.update(logger_config)to create the logger configuration.
For the rest of the configuration,
dict.update`is done on each of the top-level keys from theconfig.