Skip to content

Logging

Loggable

Mixin class that adds a logger to a class instance with extra contextual information.

Source code in src/redsun/log.py
class Loggable:
    """Mixin class that adds a logger to a class instance with extra contextual information."""

    @cached_property
    def logger(self) -> logging.LoggerAdapter[logging.Logger]:
        """Logger instance with contextual information."""
        return ContextualAdapter(logging.getLogger("redsun"), self)

logger cached property

logger: LoggerAdapter[Logger]

Logger instance with contextual information.