hynek / structlog

Simple, powerful, and fast logging for Python.

Home Page:https://www.structlog.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for stdlib's stacklevel parameter

hynek opened this issue · comments

It's been added in Python 3.8:

The third optional keyword argument is stacklevel, which defaults to 1. If greater than 1, the corresponding number of stack frames are skipped when computing the line number and function name set in the LogRecord created for the logging event. This can be used in logging helpers so that the function name, filename and line number recorded are not the information for the helper function/method, but rather its caller. The name of this parameter mirrors the equivalent one in the warnings module.

C.f. https://docs.python.org/3.11/library/logging.html#logging.Logger.debug