core.logging

Module Contents

Classes

ViURDefaultLogger

This is the ViUR-customized CloudLoggingHandler

ViURLocalFormatter

This is a formatter that injects console color sequences for debug output.

Attributes

client

requestLogger

requestLoggingRessource

logger

EXCLUDED_LOGGER_DEFAULTS

excluded_logger

handler

class core.logging.ViURDefaultLogger

Bases: google.cloud.logging.handlers.CloudLoggingHandler

This is the ViUR-customized CloudLoggingHandler

emit(record)
Parameters:

record (logging.LogRecord) –

class core.logging.ViURLocalFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)

Bases: logging.Formatter

This is a formatter that injects console color sequences for debug output.

The formatting can be modified using environment variables as follows:

  • VIUR_LOGGING_COLORIZATION can be either FULL (colorize full line) or DECENT (colorize debug level only)

  • VIUR_LOGGING_COLOR_DEBUG set debug level color

  • VIUR_LOGGING_COLOR_INFO set info level color

  • VIUR_LOGGING_COLOR_WARNING set warning level color

  • VIUR_LOGGING_COLOR_ERROR set error level color

  • VIUR_LOGGING_COLOR_CRITICAL set critical error level color

The colors can be “black”, “red”, “green”, “yellow”, “blue”, “magenta”, “cyan” and “white”.

Example configuration using viur-cli `sh VIUR_LOGGING_COLOR_WARNING=red VIUR_LOGGING_COLORIZATION=decent pipenv run viur run develop `

For details on console coloring, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

COLORS
DEFAULTS
static colorize(level, text)

Retrieving colors for given debug level, either from environment or by default.

Parameters:
  • level (str) –

  • text (str) –

Return type:

str

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.

Parameters:

record (logging.LogRecord) –

Return type:

str

core.logging.client
core.logging.requestLogger
core.logging.requestLoggingRessource
core.logging.logger
core.logging.EXCLUDED_LOGGER_DEFAULTS
core.logging.excluded_logger
core.logging.handler