oslo_log.log

OpenStack logging handler.

This module adds to logging functionality by adding the option to specify a context object when calling the various log methods. If the context object is not specified, default formatting is used. Additionally, an instance uuid may be passed as part of the log message, which is intended to make it easier for admins to find messages related to a specific instance.

It also allows setting of formatting information through conf.

class oslo_log.log.BaseLoggerAdapter(logger, extra)

Bases: logging.LoggerAdapter

property handlers
trace(msg, *args, **kwargs)
warn(msg, *args, **kwargs)

Delegate a warning call to the underlying logger.

class oslo_log.log.KeywordArgumentAdapter(logger, extra)

Bases: oslo_log.log.BaseLoggerAdapter

Logger adapter to add keyword arguments to log record’s extra data

Keywords passed to the log call are added to the “extra” dictionary passed to the underlying logger so they are emitted with the log message and available to the format string.

Special keywords:

extra

An existing dictionary of extra values to be passed to the logger. If present, the dictionary is copied and extended.

resource
A dictionary-like object containing a name key or type

and id keys.

process(msg, kwargs)

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.

Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.

exception oslo_log.log.LogConfigError(log_config, err_msg)

Bases: Exception

message = 'Error loading logging config %(log_config)s: %(err_msg)s'
oslo_log.log.getLogger(name=None, project='unknown', version='unknown')

Build a logger with the given name.

Parameters
  • name (string) – The name for the logger. This is usually the module name, __name__.

  • project (string) – The name of the project, to be injected into log messages. For example, 'nova'.

  • version (string) – The version of the project, to be injected into log messages. For example, '2014.2'.

oslo_log.log.get_default_log_levels()

Return the Oslo Logging default log levels.

Returns a copy of the list so an application can change the value and not affect the default value used in the log_opts configuration setup.

oslo_log.log.get_loggers()

Return a copy of the oslo loggers dictionary.

oslo_log.log.is_debug_enabled(conf)

Determine if debug logging mode is enabled.

oslo_log.log.register_options(conf)

Register the command line and configuration options used by oslo.log.

oslo_log.log.set_defaults(logging_context_format_string=None, default_log_levels=None)

Set default values for the configuration options used by oslo.log.

oslo_log.log.setup(conf, product_name, version='unknown')

Setup logging for the current application.

oslo_log.log.tempest_set_log_file(filename)

Provide an API for tempest to set the logging filename.

Warning

Only Tempest should use this function.

We don’t want applications to set a default log file, so we don’t want this in set_defaults(). Because tempest doesn’t use a configuration file we don’t have another convenient way to safely set the log file default.

See also

Using oslo.log