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
NOTICEpositions the notice log level between theWARNINGandINFOlevels. Refer to pull request #3 for more details.See also: The notice()method of theVerboseLoggerclass.
-
verboselogs.SPAM= 5¶ The numeric value of the ‘spam’ log level (a number).
The value of
SPAMpositions the spam log level between theDEBUGandNOTSETlevels.See also: The spam()method of theVerboseLoggerclass.
-
verboselogs.SUCCESS= 35¶ The numeric value of the ‘success’ log level (a number).
The value of
SUCCESSpositions the success log level between theWARNINGandERRORlevels. Refer to issue #4 for more details.See also: The success()method of theVerboseLoggerclass.
-
verboselogs.VERBOSE= 15¶ The numeric value of the ‘verbose’ log level (a number).
The value of
VERBOSEpositions the verbose log level between theINFOandDEBUGlevels.See also: The verbose()method of theVerboseLoggerclass.
-
verboselogs.install()[source]¶ Make
VerboseLoggerthe default logger class.The
install()function usessetLoggerClass()to configureVerboseLoggeras 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
loggingmodule.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.Loggeradds support for the additional logging methodsnotice(),spam(),success()andverbose().You can use
verboselogs.install()to makeVerboseLoggerthe 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().
-