oslo_log.formatters¶
- class oslo_log.formatters.ContextFormatter(*args, **kwargs)¶
Bases:
logging.Formatter
A context.RequestContext aware formatter configured through flags.
The flags used to set format strings are: logging_context_format_string and logging_default_format_string. You can also specify logging_debug_format_suffix to append extra formatting if the log level is debug.
The standard variables available to the formatter are listed at: http://docs.python.org/library/logging.html#formatter
In addition to the standard variables, one custom variable is available to both formatting string: isotime produces a timestamp in ISO8601 format, suitable for producing RFC5424-compliant log messages.
Furthermore, logging_context_format_string has access to all of the data in a dict representation of the context.
- format(record)¶
Uses contextstring if request_id is set, otherwise default.
- formatException(exc_info, record=None)¶
Format exception output with CONF.logging_exception_prefix.
- class oslo_log.formatters.FluentFormatter(fmt=None, datefmt=None, style='%s')¶
Bases:
logging.Formatter
A formatter for fluentd.
format() returns dict, not string. It expects to be used by fluent.handler.FluentHandler. (included in fluent-logger-python)
New in version 3.17.
- format(record)¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- formatException(exc_info, strip_newlines=True)¶
Format and return the specified exception information as a string.
This default implementation just uses traceback.print_exception()
- class oslo_log.formatters.JSONFormatter(fmt=None, datefmt=None, style='%')¶
Bases:
logging.Formatter
- format(record)¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- formatException(ei, strip_newlines=True)¶
Format and return the specified exception information as a string.
This default implementation just uses traceback.print_exception()