petri.loggin module¶
Configure a single logger.
-
class
petri.loggin.
LogDest
[source]¶ Bases:
enum.Enum
Define allowed destinations for logs.
-
CONSOLE
= 'CONSOLE'¶ Log to console
-
FILE
= 'FILE'¶ Log to file
-
-
class
petri.loggin.
LogFormatter
[source]¶ Bases:
enum.Enum
Define allowed destinations for logs.
-
COLOR
= 'COLOR'¶ pprinted, colored, for humans
-
JSON
= 'JSON'¶ JSONs, eg for filebeat or similar, for machines
-
-
class
petri.loggin.
LogLevel
[source]¶ Bases:
enum.IntEnum
Explicitly define allowed logging levels.
-
CRITICAL
= 50¶
-
DEBUG
= 10¶
-
ERROR
= 40¶
-
INFO
= 20¶
-
NOTSET
= 0¶
-
TRACE
= 1¶
-
WARNING
= 30¶
-
-
petri.loggin.
configure_logging
(name, level, dest, formatter, log_file, kidnap_loggers=False)[source]¶ Setup logging with (hopefully) sane defaults.
Parameters: - name – Name for the logger.
- level (
LogLevel
) – Level from where to start logging. - dest (
LogDest
) – Whether to log to file or console. - formatter (
LogFormatter
) – Whether to output data as json or colored, parsed logs. - log_file (
Path
) – Where to store logfiles. Only used ifdest='FILE'
. - kidnap_loggers – Whether to configure the loggers on just instantiate one.
Returns: The configured logger.