pint.logging.LogFilter
- class pint.logging.LogFilter(onlyonce=None, never=None, onlyonce_level='INFO')[source]
Bases:
object
Custom logging filter for
loguru
. Define some messages that are never seen (e.g., Deprecation Warnings). Others that will only be seen once. Filtering of those is done on the basis of regular expressions.Define regexs for messages that will only be seen once. Use
\S+
for a variable that might change. If a message comes through with a new value for that variable, it will be seen.Make sure to escape other regex commands like
()
.Each message starts with
state = False
. Once it has been emitted, that changes to a list of the messages so that it can keep track. These are only suppressed when issued at level onlyonce_level or lower (e.g., if onlyonce_level isINFO
, thenWARNING
will always come through)They should be defined as:
r”Error message”: False
where the
False
tracks whether or not the message has been issued at all.- Parameters:
onlyonce (list, optional) – list of messages that should only be issued once if at
INFO
or below. Checked usingre.match
, so must match from beginning of message.never (list, optional) – list of messages that should never be seen. Checked using
re.search
, so can match anywhere in message.onlyonce_level (str, optional) – level below which messages will only be shown once
Methods
filter
(record)Filter the record based on
record["message"]
andrecord["level"]
If this returns s,``False``, the message is not seen