thinlog.log module#
Logger adapter that converts keyword arguments into extra fields.
- class thinlog.log.KeywordFriendlyLogger(logger: Logger, extra: dict[str, Any] | None = None)[source]#
Bases:
LoggerAdapter[Logger]A
logging.LoggerAdapterthat passes arbitrary keyword arguments as extra fields.Standard
loggingrequires extra data to be wrapped in anextradict.KeywordFriendlyLoggerlets callers pass keyword arguments directly – they are automatically moved into extra so that filters, formatters, and handlers can access them as record attributes.- Parameters:
logger – The underlying
logging.Loggerto adapt.extra – Optional default extra fields attached to every record.
- ignored_meta_keys = ('exc_info', 'stack_info', 'stacklevel')#
- process(msg: Any, metadata: MutableMapping[str, Any]) tuple[Any, MutableMapping[str, Any]][source]#
Move keyword arguments into the extra dict.
Keys listed in
ignored_meta_keysare left in metadata so that the standard logging machinery can handle them.- Parameters:
msg – The log message.
metadata – Keyword arguments passed to the logging call.
- Returns:
A
(msg, metadata)tuple ready for the underlying logger.