Configure kanta event loggers at import time, inheriting the root level.
configure_logging() now runs with default arguments when kanta.logging is imported, attaching a plain stderr handler with propagate=False to the event loggers (kanta.bootstrap/migration/transaction) that carry Kanta-rendered output. No levels are set by default, so event output inherits the effective root level: a framework switching root between INFO in development and WARNING in production governs Kanta output too. Other configure_logging changes: channel enable flags use logger.disabled (propagate toggling no longer silences now that event loggers have their own handler), skiproot=False removes Kanta's handler and re-enables propagation so the root logger renders event output, and debug=True lifts only the DEBUG-emitting loggers (bootstrap, migration) to DEBUG instead of setting a level on the "kanta" parent.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
from kanta.serialization import JsonSerializer, MsgPackSerializer
|
||||
@@ -12,3 +14,20 @@ from kanta.serialization import JsonSerializer, MsgPackSerializer
|
||||
)
|
||||
def format_config(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _kanta_event_loggers_propagate():
|
||||
"""Let kanta's event loggers propagate so caplog captures their records.
|
||||
|
||||
Kanta configures them with ``propagate = False`` at import time, which
|
||||
would hide their records from pytest's root-logger capture handler.
|
||||
"""
|
||||
names = ("kanta.bootstrap", "kanta.migration", "kanta.transaction")
|
||||
loggers = [logging.getLogger(name) for name in names]
|
||||
previous = [logger.propagate for logger in loggers]
|
||||
for logger in loggers:
|
||||
logger.propagate = True
|
||||
yield
|
||||
for logger, propagate in zip(loggers, previous):
|
||||
logger.propagate = propagate
|
||||
|
||||
Reference in New Issue
Block a user