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.dictConfig is 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.Logger

The logger instance.

Notes

Internally, the logging configuration is placed into logging.config.dictConfig. base_config defines a set of handlers, formatters, and filters that separate out the different levels as follows:

default

Handles logging.WARNING and above.

debug

Handles logging.DEBUG exclusively.

info

Handles logging.INFO exclusively.

Given the defaults, a logger is created with the given name, with the levels as described above.

To make modifications:

  • The pair of parameters name and logger_config together make up the dictionary that is the value to the top-level key loggers.

  • The parameter config defines the rest of the top-level keys for configuration dictionary.

  • When the parameter merge is True, the following happens:

    • For the formatters dictionary, the dictionary for the key name is created by first creating the default dictionary, and then doing an dict.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 the config.