Reputation: 29342
Is there a way to get the effective log level of a structlog logger? I want to do something like the following:
import structlog
logger = structlog.get_logger()
if logger.isEnabledFor(DEBUG):
some_expensive_report()
I'm looking for something like isEnabledFor from the standard library logging module. Does such a thing exist?
Update: It looks like I can use logger.bind().isEnabledFor()
, but only if I configure struct log with structlog.configure(wrapper_class=structlog.stdlib.BoundLogger)
. Is this the answer?
Upvotes: 0
Views: 811
Reputation: 4126
As long as you use structlog's standard library integration, you can use the method proxies that you've found yourself in the end. For structlog's much faster native levels there's no such functionality yet.
Upvotes: 1