DecoratedLogger

class coba.context.DecoratedLogger

A Logger which decorates a logger.

Constructors

__init__(pre_decorators: Sequence[Filter], logger: Logger, post_decorators: Sequence[Filter])

Instantiate DecoratedLogger.

Parameters:
  • pre_decorators – A sequence of decorators to be applied before the base logger.

  • logger – The base logger we are decorating.

  • post_decorators – A sequence of decorators to be applied after the base logger.

Methods

log(message: str | Exception) ContextManager[Logger]

Log a message or exception to the sink.

Parameters:

message – The message or exception that should be logged.

Returns:

A ContextManager that controls hierarchy.

time(message: str) ContextManager[Logger]

Log a timed message to the sink.

Parameters:

message – The message that should be logged.

Returns:

A ContextManager that controls when timing stops.

undecorate() Logger

Remove the decorator.

Returns:

The original logger without a decorator.

Attributes

sink