libera_utils.logutil.JsonLogFormatter#

class libera_utils.logutil.JsonLogFormatter(*args, add_log_record_attrs: Tuple[str, ...] | None = None, add_asctime: bool = True, **kwargs)#

Bases: Formatter

Altered version of the CloudWatchLogFormatter provided in the watchtower library

Methods

converter([seconds])

Convert seconds since the Epoch to a time tuple expressing local time.

format(record)

Format log message to a string

formatException(ei)

Format and return the specified exception information as a string.

formatStack(stack_info)

This method is provided as an extension point for specialized formatting of stack information.

formatTime(record[, datefmt])

Return the creation time of the specified LogRecord as formatted text.

usesTime()

Check if the format uses the creation time of the record.

formatMessage

__init__(*args, add_log_record_attrs: Tuple[str, ...] | None = None, add_asctime: bool = True, **kwargs)#
Parameters:
  • add_log_record_attrs (Optional, tuple) – Tuple of log record attributes to add to the resulting structured JSON structure that comes out of the logging formatter.

  • add_asctime (bool) – If True, adds an ASCII (ISO 8601-like) timestamp to the log record. Default True.

Methods

format(record)

Format log message to a string

Attributes

default_msec_format

default_time_format

format(record: LogRecord) str#

Format log message to a string

Parameters:

record (logging.LogRecord) – Log record object containing the logged message, which may be a dict (Mapping) or a string