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 the WARNING and INFO levels. Refer to pull request #3 for more details.

See also:The notice() method of the VerboseLogger class.
verboselogs.SPAM = 5

The numeric value of the ‘spam’ log level (a number).

The value of SPAM positions the spam log level between the DEBUG and NOTSET levels.

See also:The spam() method of the VerboseLogger class.
verboselogs.SUCCESS = 35

The numeric value of the ‘success’ log level (a number).

The value of SUCCESS positions the success log level between the WARNING and ERROR levels. Refer to issue #4 for more details.

See also:The success() method of the VerboseLogger class.
verboselogs.VERBOSE = 15

The numeric value of the ‘verbose’ log level (a number).

The value of VERBOSE positions the verbose log level between the INFO and DEBUG levels.

See also:The verbose() method of the VerboseLogger class.
verboselogs.install()[source]

Make VerboseLogger the default logger class.

The install() function uses setLoggerClass() to configure VerboseLogger as the default class for all loggers created by logging.getLogger() after install() 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 methods notice(), spam(), success() and verbose().

You can use verboselogs.install() to make VerboseLogger the default logger class.

notice(msg, *args, **kw)[source]

Log a message with level NOTICE. The arguments are interpreted as for logging.debug().

spam(msg, *args, **kw)[source]

Log a message with level SPAM. The arguments are interpreted as for logging.debug().

success(msg, *args, **kw)[source]

Log a message with level SUCCESS. The arguments are interpreted as for logging.debug().

verbose(msg, *args, **kw)[source]

Log a message with level VERBOSE. The arguments are interpreted as for logging.debug().

verboselogs.pylint

Pylint plugin to fix invalid errors about the logging module.

verboselogs.pylint.register(linter)[source]

No-op (required by Pylint).

verboselogs.pylint.verboselogs_class_transform(cls)[source]

Make Pylint aware of our custom logger methods.

verboselogs.pylint.verboselogs_module_transform(mod)[source]

Make Pylint aware of our custom log levels.