API documentation¶
The following documentation is based on the source code of version 1.7 of the verboselogs package.
verboselogs
¶
Custom log levels for Python’s logging
module.
The verboselogs
module defines the NOTICE
, SPAM
,
SUCCESS
and VERBOSE
constants, the VerboseLogger
class
and the add_log_level()
and install()
functions.
At import time add_log_level()
is used to register the custom log
levels NOTICE
, SPAM
, SUCCESS
and VERBOSE
with
Python’s logging
module.
-
verboselogs.
NOTICE
= 25¶ The numeric value of the ‘notice’ log level (a number).
The value of
NOTICE
positions the notice log level between theWARNING
andINFO
levels. Refer to pull request #3 for more details.See also: The notice()
method of theVerboseLogger
class.
-
verboselogs.
SPAM
= 5¶ The numeric value of the ‘spam’ log level (a number).
The value of
SPAM
positions the spam log level between theDEBUG
andNOTSET
levels.See also: The spam()
method of theVerboseLogger
class.
-
verboselogs.
SUCCESS
= 35¶ The numeric value of the ‘success’ log level (a number).
The value of
SUCCESS
positions the success log level between theWARNING
andERROR
levels. Refer to issue #4 for more details.See also: The success()
method of theVerboseLogger
class.
-
verboselogs.
VERBOSE
= 15¶ The numeric value of the ‘verbose’ log level (a number).
The value of
VERBOSE
positions the verbose log level between theINFO
andDEBUG
levels.See also: The verbose()
method of theVerboseLogger
class.
-
verboselogs.
install
()[source]¶ Make
VerboseLogger
the default logger class.The
install()
function usessetLoggerClass()
to configureVerboseLogger
as the default class for all loggers created bylogging.getLogger()
afterinstall()
has been called. Here’s how it works:import logging import verboselogs verboselogs.install() logger = logging.getLogger(__name__) # will be a VerboseLogger instance
-
verboselogs.
add_log_level
(value, name)[source]¶ Add a new log level to the
logging
module.Parameters: - value – The log level’s number (an integer).
- name – The name for the log level (a string).
-
class
verboselogs.
VerboseLogger
(*args, **kw)[source]¶ Custom logger class to support the additional logging levels.
This subclass of
logging.Logger
adds support for the additional logging methodsnotice()
,spam()
,success()
andverbose()
.You can use
verboselogs.install()
to makeVerboseLogger
the default logger class.-
notice
(msg, *args, **kw)[source]¶ Log a message with level
NOTICE
. The arguments are interpreted as forlogging.debug()
.
-
spam
(msg, *args, **kw)[source]¶ Log a message with level
SPAM
. The arguments are interpreted as forlogging.debug()
.
-
success
(msg, *args, **kw)[source]¶ Log a message with level
SUCCESS
. The arguments are interpreted as forlogging.debug()
.
-
verbose
(msg, *args, **kw)[source]¶ Log a message with level
VERBOSE
. The arguments are interpreted as forlogging.debug()
.
-