pillar.logging 🔗
LoggingMixin 🔗
Bases: LoggingMixinBase
Adds shortcut logging methods to a class
Expects that a logging.Logger
exists at self.logger
critical 🔗
Log a CRITICAL message
Something is on fire. We somehow caught it but we probably need to exit now. If we keep going more things may catch on fire.
In a larger system, someone is probably going to get paged over this. An end user is definitely going to get an error message, probably not even a useful one, just a HTTP 500.
error 🔗
Log an ERROR message
Something bad has happened but we caught it. We might be able to continue, but other things might start breaking. We can probably still safely exit.
In a larger system, this will likely cause a gentle alert to be placed somewhere. An end user might receive a useful error message (like a HTTP 4xx 5xx).
get_logger
classmethod
🔗
Get a logging.Logger
for this class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
optional prefix for the logger name |
''
|
info 🔗
Log an INFO message
Print something to the screen/logfile so we know what is happening
vdebug 🔗
Log a Verbose Debug (VDEBUG) message.
More than debug, less than everything.
vvdebug 🔗
Log a Very Verbose Debug (VVDEBUG) message.
When you're tired of finding the bug and want to log everything.
warning 🔗
Log a WARNING message
Something is wrong but we likely can recover or skip it without issue.
In a larger system this will likely just go to centralised logging.
LoggingMixinBase 🔗
Base class for logging mixins
get_logger
classmethod
🔗
Get a logging.Logger
for this class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
optional prefix for the logger name |
''
|
NotFilter 🔗
Bases: Filter
Ignore the given logger (and all subloggers).
Is the opposite of logging.Filter
.
References
- https://docs.python.org/3/library/logging.html#filter-objects
UnderscoreLoggingMixin 🔗
Bases: LoggingMixinBase
Add shortcut logging methods to a class with underscore (_
) prefix
Expects that a logging.Logger
exists at self._logger
.
get_logger
classmethod
🔗
Get a logging.Logger
for this class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
optional prefix for the logger name |
''
|
get_log_level 🔗
Get the log level based on the default log level.
This function essentially adds a "verbosity level" per "major log level" lower than the default.
For example, if default_level == DEBUG
, then verbosity == 1
will return VDEBUG
and
verbosity >= 2
will return VVDBEUG
. For any defaul_level > INFO
will always use
4 levels of verbosity (INFO
, DEBUG
, VDEBUG
, VVDEBUG
).
get_logger_name_for_class 🔗
Get a logger name based on the qualified name of a class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls |
Type[object]
|
object to inspect |
required |
prefix |
str
|
optional prefix for the logger name. |
''
|
get_logger_name_for_instance 🔗
Get a logger name based on the qualified name of this instance's class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance |
object
|
object to inspect |
required |
prefix |
str
|
optional prefix for the logger name. |
''
|
logging_file_handler_errors_kwargs 🔗
Generate FileHandler keyword argument if it is supported by this python version.
If it is not supported contains an empty dictionary.
To use it unpack it like so FileHandler(**logging_file_handler_errors_kwargs())