Skip to content

loggers

Logging functions.

LoggerAdapter ¤

LoggerAdapter(prefix, logger)

Bases: logging.LoggerAdapter

A logger adapter to prefix messages.

Parameters:

Name Type Description Default
prefix str

The string to insert in front of every message.

required
logger logging.Logger

The logger instance.

required
Source code in src/mkdocs_iframe/loggers.py
14
15
16
17
18
19
20
21
22
def __init__(self, prefix: str, logger: logging.Logger):
    """Initialize the object.

    Arguments:
        prefix: The string to insert in front of every message.
        logger: The logger instance.
    """
    super().__init__(logger, {})
    self.prefix = prefix

process ¤

process(msg, kwargs)

Process the message.

Parameters:

Name Type Description Default
msg str

The message:

required
kwargs MutableMapping[str, Any]

Remaining arguments.

required

Returns:

Type Description
tuple[Any, MutableMapping[str, Any]]

The processed message, and the remaining arguments.

Source code in src/mkdocs_iframe/loggers.py
24
25
26
27
28
29
30
31
32
33
34
def process(self, msg: str, kwargs: MutableMapping[str, Any]) -> tuple[Any, MutableMapping[str, Any]]:
    """Process the message.

    Arguments:
        msg: The message:
        kwargs: Remaining arguments.

    Returns:
        The processed message, and the remaining arguments.
    """
    return f"{self.prefix}: {msg}", kwargs

get_logger ¤

get_logger(name)

Return a pre-configured logger.

Parameters:

Name Type Description Default
name str

The name to use with logging.getLogger.

required

Returns:

Type Description
LoggerAdapter

A logger configured to work well in MkDocs.

Source code in src/mkdocs_iframe/loggers.py
37
38
39
40
41
42
43
44
45
46
47
48
def get_logger(name: str) -> LoggerAdapter:
    """Return a pre-configured logger.

    Arguments:
        name: The name to use with `logging.getLogger`.

    Returns:
        A logger configured to work well in MkDocs.
    """
    logger = logging.getLogger(f"mkdocs.plugins.{name}")
    logger.addFilter(warning_filter)
    return LoggerAdapter(name, logger)