Verbose Logging Levels
The `verboselogs` package extends Python's standard `logging` module by introducing additional log levels: NOTICE, SPAM, SUCCESS, and VERBOSE. These levels are strategically positioned within the existing hierarchy (e.g., NOTICE between WARNING and INFO, VERBOSE between INFO and DEBUG) to provide more granular control over log output. Version 1.7 is currently active, and its release cadence has been stable, with the last update in 2017.
Warnings
- gotcha Mixing standard `logging.getLogger()` with `verboselogs.VerboseLogger()` for the same logger name can lead to unexpected behavior if not handled carefully. Always ensure you consistently use `VerboseLogger` for loggers where custom levels are expected, or explicitly call `verboselogs.install()` to patch the root logger.
- gotcha When integrating with other logging configuration methods (e.g., `logging.basicConfig` or file-based configurations), ensure that the log level of handlers and formatters is set appropriately to allow the new, lower `SPAM` and `VERBOSE` levels to pass through. Default configurations often filter out anything below `INFO` or `WARNING`.
Install
-
pip install verboselogs
Imports
- VerboseLogger
from verboselogs import VerboseLogger
- NOTICE
import verboselogs; verboselogs.NOTICE
- SPAM
import verboselogs; verboselogs.SPAM
- SUCCESS
import verboselogs; verboselogs.SUCCESS
- VERBOSE
import verboselogs; verboselogs.VERBOSE
Quickstart
import logging
import verboselogs
logger = verboselogs.VerboseLogger('my-app')
logger.addHandler(logging.StreamHandler())
logger.setLevel(verboselogs.VERBOSE)
logger.spam('This is a SPAM message.')
logger.verbose('This is a VERBOSE message, providing detailed info.')
logger.debug('This is a standard DEBUG message.')
logger.info('This is a standard INFO message.')
logger.notice('This is a NOTICE message, between INFO and WARNING.')
logger.success('This is a SUCCESS message, confirming an operation.')
logger.warning('This is a standard WARNING message.')