pint.logging.setup
- pint.logging.setup(level: str = 'INFO', sink: str | ~pathlib.Path | ~typing.IO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, format: str = '<level>{level: <8}</level> ({name: <30}): <level>{message}</level>', filter: callable = <pint.logging.LogFilter object>, usecolors: bool = True, colors: ~typing.Dict[str, str] = {'DEBUG': '<fg #b790d4><bold>'}, capturewarnings: bool = True, removeprior: bool = True) int[source]
Setup the PINT logging using
loguruThis involves removing previous loggers and adding a new one at the requested level
- Parameters:
level (str, optional) – Logging level, unless overridden by
$LOGURU_LEVELsink (file-like object, str, or other object accepted by
loguru.Logger.add(), optional) – Destination for the logging messagesformat (str, optional) – Format string for the logging messages, unless overridden by
$LOGURU_FORMAT. See loguru documentation for full set of optionsfilter (callable, optional) – Should be a
LogFilteror similar which returnsTrueif a message will be seen andFalseotherwise. The default instance can be modified to change the messages that are never seen/only seen onceusecolors (bool, optional) – Should it use colors at all
colors (dict, optional) – Dict of
level,formatpairs to override the color/format settings for any levelcapturewarnings (bool, optional) – Whether or not messages emitted by
warnings.warn()should be included in the logging outputremoveprior (bool, optional) – Whether or not to remove prior loggers
- Returns:
An identifier associated with the added sink and which should be used to remove it.
- Return type:
Example
>>> import pint.logging >>> import sys >>> format = "<level>{level: <8}</level> ({name: <30}): <level>{message}</level>" # turn off colors if your terminal does not play well with them >>> pint.logging.setup(level="DEBUG", sink=sys.stderr, format=format, filter=pint.logging.LogFilter(), usecolors=False)