pygcam.log

This module allows modules to register themselves for logging which is turned on after the app reads configuration information. Modules call

logger = pygcam.log.getLogger(__name__)

as a top-level statement, evaluated at load time. This returns the logger, which may not yet be configured. When the configuration file has been read, all registered loggers are initialized, and all subsequently registered loggers are initialized upon instantiation.

API

pygcam.log.configureLogs(force=False)

Do basicConfig setup and configure package loggers based on the information in the config instance given. Unless force == True, loggers with handlers will not be reconfigured.

Parameters:force – (bool) if True, reconfigure the logs even if already configured.
Returns:none
pygcam.log.getLogger(name)

Register a logger, which will be set up after the configuration file is read.

Parameters:name – the name of the logger, conventionally passed as __name__.
Returns:a logging logger instance
pygcam.log.parseLevels(levelStr=None)

Get log levels for pygcam as a whole or for indicated modules individually. Modules starting with a ‘.’ are interpreted to be in pygcam, i.e., “.config” is equivalent to “pygcam.config”. Example: LogLevel = WARNING, .tool:DEBUG, .utils:INFO, .mcs.util:INFO, my_plugin:DEBUG

Parameters:levelStr – a comma-delimited string of module:logLevel values. If no ‘:’ is present, the value is treated as the default logLevel for pygcam. If levelStr is None, the value of the variable ‘GCAM.LogLevel’ is used.
Returns:(dict) of log levels, keyed by module names
pygcam.log.setLogLevels(levelStr)

Set the logging level string, which can define levels for packages and/or modules. Must call configureLogs(force=True) afterwards. Level string can be a single level, which is used as the default for all modules, or module-specific settings, e.g., “WARNING, .tool:DEBUG, .utils:INFO, .mcs.util:INFO, my_plugin:DEBUG”

Parameters:levelStr – (str) comma-delimited module:LEVEL pairs, or just a single LEVEL
Returns:none