You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find myself only wanting certain fields included in my logging at a few select log levels. Something like:
classProcessAtLogLevels:
"""Evaluate a chain of processors at a given set log levels. Args: levels: Log levels at which to evaluate processor chain. processors: A chain of *structlog* processors that is used to process entries at the given log levels. """def__init__(self, levels: int|Collection[int], *, processors: Sequence[Processor] = ()):
self._levels=levelsifisinstance(levels, Collection) else (levels,)
self._processors=processorsdef__call__(self, logger: WrappedLogger, method_name: str, event_dict: EventDict) ->EventDict:
ifstructlog.processors.NAME_TO_LEVEL[method_name] inself._levels:
forprocessorinself._processors:
event_dict=processor(logger, method_name, event_dict)
returnevent_dict
I'll end up with something like this in my processor chain:
I find myself only wanting certain fields included in my logging at a few select log levels. Something like:
I'll end up with something like this in my processor chain:
This will only add line numbers and pathname at the DEBUG and CRITICAL log levels.
The text was updated successfully, but these errors were encountered: