logger ¤
This module contains logging utilities.
We provide the patch_loggers
function so dependant libraries can patch loggers as they see fit.
For example, to fit in the MkDocs logging configuration and prefix each log message with the module name:
import logging
from griffe.logger import patch_loggers
class LoggerAdapter(logging.LoggerAdapter):
def __init__(self, prefix, logger):
super().__init__(logger, {})
self.prefix = prefix
def process(self, msg, kwargs):
return f"{self.prefix}: {msg}", kwargs
def get_logger(name):
logger = logging.getLogger(f"mkdocs.plugins.{name}")
return LoggerAdapter(name, logger)
patch_loggers(get_logger)
Classes:
-
LogLevel
–Enumeration of available log levels.
Functions:
-
get_logger
–Create and return a new logger instance.
-
patch_loggers
–Patch loggers.
get_logger ¤
get_logger(name: str) -> _Logger
Create and return a new logger instance.
Parameters:
-
name
(str
) –The logger name.
Returns:
-
_Logger
–The logger.
Source code in src/griffe_typedoc/logger.py
74 75 76 77 78 79 80 81 82 83 |
|
patch_loggers ¤
Patch loggers.
Parameters:
-
get_logger_func
(Callable[[str], Any]
) –A function accepting a name as parameter and returning a logger.
Source code in src/griffe_typedoc/logger.py
86 87 88 89 90 91 92 |
|