Ir para o conteúdo

events

module wittgenstein_observability.events

Classes

  • JsonLineFormatter — Formats LogRecord as a single line JSON ready for ingestion / jq.

Functions

wittgenstein_observability.events.JsonLineFormatter

class JsonLineFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)

Bases : logging.Formatter

Formats LogRecord as a single line JSON ready for ingestion / jq.

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, :meth:str.format ({}) formatting or :class:string.Template formatting in your format string.

.. versionchanged:: 3.2 Added the style parameter.

Methods

wittgenstein_observability.events.JsonLineFormatter.format

method JsonLineFormatter.format(record: logging.LogRecord) → str

wittgenstein_observability.events.configure_event_file_handler

configure_event_file_handler(log_dir: Path, filename: str = 'chat.jsonl') → Path

Attaches a TimedRotatingFileHandler to the structured events logger.