Skip to content

make_record_with_extra

faststream.log.formatter.make_record_with_extra #

make_record_with_extra(
    self: logging.Logger,
    name: str,
    level: int,
    fn: str,
    lno: int,
    msg: str,
    args: Tuple[str],
    exc_info: Optional[
        Union[
            Tuple[
                Type[BaseException],
                BaseException,
                Optional[TracebackType],
            ],
            Tuple[None, None, None],
        ]
    ],
    func: Optional[str] = None,
    extra: Optional[Mapping[str, object]] = None,
    sinfo: Optional[str] = None,
) -> logging.LogRecord

Creates a log record with additional information.

PARAMETER DESCRIPTION
self

The logger object.

TYPE: Logger

name

The name of the logger.

TYPE: str

level

The logging level.

TYPE: int

fn

The filename where the log message originated.

TYPE: str

lno

The line number where the log message originated.

TYPE: int

msg

The log message.

TYPE: str

args

The arguments for the log message.

TYPE: Tuple[str]

exc_info

Information about an exception.

TYPE: Optional[Union[Tuple[Type[BaseException], BaseException, Optional[TracebackType]], Tuple[None, None, None]]]

func

The name of the function where the log message originated.

TYPE: Optional[str] DEFAULT: None

extra

Additional information to include in the log record.

TYPE: Optional[Mapping[str, object]] DEFAULT: None

sinfo

Stack information.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
LogRecord

The log record.

Note

If extra is None, it will be set to the value of context.get_local("log_context").

Note

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

Source code in faststream/log/formatter.py
def make_record_with_extra(
    self: logging.Logger,
    name: str,
    level: int,
    fn: str,
    lno: int,
    msg: str,
    args: Tuple[str],
    exc_info: Optional[
        Union[
            Tuple[Type[BaseException], BaseException, Optional[TracebackType]],
            Tuple[None, None, None],
        ]
    ],
    func: Optional[str] = None,
    extra: Optional[Mapping[str, object]] = None,
    sinfo: Optional[str] = None,
) -> logging.LogRecord:
    """Creates a log record with additional information.

    Args:
        self: The logger object.
        name: The name of the logger.
        level: The logging level.
        fn: The filename where the log message originated.
        lno: The line number where the log message originated.
        msg: The log message.
        args: The arguments for the log message.
        exc_info: Information about an exception.
        func: The name of the function where the log message originated.
        extra: Additional information to include in the log record.
        sinfo: Stack information.

    Returns:
        The log record.

    Note:
        If `extra` is `None`, it will be set to the value of `context.get_local("log_context")`.
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    if extra is None:
        extra = context.get_local("log_context")

    record = original_makeRecord(
        self,
        name,
        level,
        fn,
        lno,
        msg,
        args,
        exc_info,
        func,
        extra,
        sinfo,
    )

    return record

Last update: 2023-11-13