pint.logging.setup
- pint.logging.setup(level='INFO', sink=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, format='<level>{level: <8}</level> ({name: <30}): <level>{message}</level>', filter=<pint.logging.LogFilter object>, usecolors=True, colors={'DEBUG': '<fg #b790d4><bold>'}, capturewarnings=True, removeprior=True)[source]
Setup the PINT logging using
loguru
This involves removing previous loggers and adding a new one at the requested level
- Parameters:
level (str, optional) – Logging level, unless overridden by
$LOGURU_LEVEL
sink (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
LogFilter
or similar which returnsTrue
if a message will be seen andFalse
otherwise. 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
,format
pairs 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)