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.
34 lines
942 B
Python
34 lines
942 B
Python
import logging
|
|
|
|
import pytest
|
|
|
|
from kanta.serialization import JsonSerializer, MsgPackSerializer
|
|
|
|
|
|
@pytest.fixture(
|
|
params=[
|
|
("json", JsonSerializer),
|
|
("msgpack", MsgPackSerializer),
|
|
],
|
|
ids=["json", "msgpack"],
|
|
)
|
|
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
|