Skip to content

blackbull.logger

blackbull.logger

log(fn)

Decorator: log call arguments at DEBUG level.

Automatically uses the logger of the module where @log is applied, determined by inspecting the caller's frame at decoration time.

When the module logger is not enabled for DEBUG at decoration time (i.e. at import), the decorator is a zero-cost no-op: the original function is returned unwrapped, so there is no extra function-call overhead in production. The trade-off is that raising the log level to DEBUG after modules have been imported will not activate logging for already-decorated functions.

setup_async_logging(handlers=None)

Install a QueueHandler on the blackbull logger hierarchy.

After this call every logger.debug/info/warning in the event loop enqueues a LogRecord and returns immediately. A daemon thread (QueueListener) drains the queue and forwards records to handlers.

Idempotent — a second call before :func:teardown_async_logging is a no-op.

Parameters

handlers: Handlers the background listener should write to. Defaults to the non-NullHandler handlers already on the blackbull logger, or a single StreamHandler(stderr) when none exist.

teardown_async_logging()

Stop the QueueListener and restore a NullHandler on blackbull.