Skip to content

LoggingMixin

faststream.broker.core.mixins.LoggingMixin #

LoggingMixin(
    *args: Any,
    logger: Optional[logging.Logger] = access_logger,
    log_level: int = logging.INFO,
    log_fmt: Optional[
        str
    ] = "%(asctime)s %(levelname)s - %(message)s",
    **kwargs: Any
)

A mixin class for logging.

METHOD DESCRIPTION
fmt

getter method for _fmt attribute

_get_log_context

returns a dictionary with log context information

_log

logs a message with optional log level, extra data, and exception info

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Initialize the class.

PARAMETER DESCRIPTION
*args

Variable length argument list

TYPE: Any DEFAULT: ()

logger

Optional logger object

TYPE: Optional[Logger] DEFAULT: access_logger

log_level

Log level (default: logging.INFO)

TYPE: int DEFAULT: INFO

log_fmt

Log format (default: "%(asctime)s %(levelname)s - %(message)s")

TYPE: Optional[str] DEFAULT: '%(asctime)s %(levelname)s - %(message)s'

**kwargs

Arbitrary keyword arguments

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
None

None

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Source code in faststream/broker/core/mixins.py
def __init__(
    self,
    *args: Any,
    logger: Optional[logging.Logger] = access_logger,
    log_level: int = logging.INFO,
    log_fmt: Optional[str] = "%(asctime)s %(levelname)s - %(message)s",
    **kwargs: Any,
) -> None:
    """Initialize the class.

    Args:
        *args: Variable length argument list
        logger: Optional logger object
        log_level: Log level (default: logging.INFO)
        log_fmt: Log format (default: "%(asctime)s %(levelname)s - %(message)s")
        **kwargs: Arbitrary keyword arguments

    Returns:
        None
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    self.logger = logger
    self.log_level = log_level
    self._fmt = log_fmt

fmt property #

fmt: str

log_level instance-attribute #

log_level = log_level

logger instance-attribute #

logger = logger

Last update: 2023-11-13