This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.1 docs or all OpenStack docs too.

The nova.log Module

Nova 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.

It also allows setting of formatting information through flags.

class nova.log.NovaFormatter(fmt=None, datefmt=None)

Bases: logging.Formatter

A nova.context.RequestContext aware formatter configured through flags.

The flags used to set format strings are: logging_context_foramt_string and logging_default_format_string. You can also specify logging_debug_format_suffix to append extra formatting if the log level is debug.

For information about what variables are available for the formatter see: http://docs.python.org/library/logging.html#formatter

format(record)

Uses contextstring if request_id is set, otherwise default

formatException(exc_info, record=None)

Format exception output with FLAGS.logging_exception_prefix

class nova.log.NovaLogger(name, level=0)

Bases: logging.Logger

NovaLogger manages request context and formatting.

This becomes the class that is instanciated by logging.getLogger.

addHandler(handler)

Each handler gets our custom formatter

audit(msg, *args, **kwargs)

Shortcut for our AUDIT level

exception(msg, *args, **kwargs)

Logging.exception doesn’t handle kwargs, so breaks context

setup_from_flags()

Setup logger from flags

class nova.log.NovaRootLogger(name, level=0)

Bases: nova.log.NovaLogger

setup_from_flags()

Setup logger from flags

nova.log.audit(msg, *args, **kwargs)

Shortcut for logging to root log with sevrity ‘AUDIT’.

nova.log.handle_exception(type, value, tb)
nova.log.reset()

Resets logging handlers. Should be called if FLAGS changes.

nova.log.setup()

Setup nova logging.