Colorlog
Introduction
The ColorLog Extension provides the ColorLogHandler for logging, and is a sub-class and drop-in replacement for the default log handler LoggingLogHandler.
Documentation References:
API References:
Requirements
Colorlog
Applications using Cement <3.0.8 should continue to include colorlog in their dependencies.
Installation
pip install cement[colorlog]Configuration
This handler honors the following settings under a [log.colorlog] section of the configuration:
Setting
Description
level
The level to display logs for. One of INFO, WARNING, ERROR, FATAL, DEBUG. Default: INFO
file
The filesystem path of the log file. Default: None
to_console
Whether or not to log to console. Default: True
rotate
Whether or not rotate the log file. Default: False
max_bytes
Maximum file size (in bytes) until the log file is rotated (if rotation is enabled). Default: 512000
max_files
Maximum number of files to keep when rotating is enabled. Default: 4
colorize_file_log
Whether or not to colorize the log file. Default: False
colorize_console_log
Whether or not to colorize the console log. Default: True
Note that there are precautions in place to disable colorized logging if the session is not a valid TTY via sys.stdout.istty()
A sample config section might look like:
Usage
Last updated