thinlog.formatters.json module#
JSON formatter with rich exception context via structlog.
- class thinlog.formatters.json.JsonFormatter(show_locals: bool = False, **kwargs: Any)[source]#
Bases:
FormatterSerialize the full log record as a JSON string.
Exception tracebacks are converted to structured dicts using
structlog.tracebacks.ExceptionDictTransformer, and stack-info frames are extracted viaparse_stack_info().- Parameters:
show_locals – If
True, local variables are included in exception tracebacks.
- formatException(ei: tuple[type[BaseException], BaseException, TracebackType | None] | tuple[None, None, None]) str[source]#
Format exception info as a JSON string, falling back to the standard formatter.
- classmethod format_exception(ei: tuple[type[BaseException], BaseException, TracebackType | None] | tuple[None, None, None]) Any[source]#
Transform exception info into a structured dict via structlog.
- classmethod format_record(record: LogRecord) dict[str, Any][source]#
Convert a
LogRecordto a plain dict.Handles
exc_info(via structlog transformer) andstack_info(viaparse_stack_info()).
- transformer: ClassVar[ExceptionDictTransformer]#