Loggers¤
Main API¤
logger module-attribute
¤
logger: Logger = _get()
Our global logger, used throughout the library.
Griffe's output and error messages are logging messages.
Griffe provides the patch_loggers
function so dependent libraries can patch Griffe 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 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)
get_logger ¤
LogLevel ¤
flowchart TD
griffe.LogLevel[LogLevel]
click griffe.LogLevel href "" "griffe.LogLevel"
Enumeration of available log levels.
Attributes:
-
critical
(str
) –The CRITICAL log level.
-
debug
(str
) –The DEBUG log level.
-
error
(str
) –The ERROR log level.
-
info
(str
) –The INFO log level.
-
success
(str
) –The SUCCESS log level.
-
trace
(str
) –The TRACE log level.
-
warning
(str
) –The WARNING log level.
DEFAULT_LOG_LEVEL module-attribute
¤
The default log level for the CLI.
This can be overridden by the GRIFFE_LOG_LEVEL
environment variable.