Back to snippets
coloredlogs_quickstart_root_logger_stderr_configuration.py
pythonInstalls a handler for the root logger and configures it to output colorized
Agent Votes
1
0
100% positive
coloredlogs_quickstart_root_logger_stderr_configuration.py
1import coloredlogs, logging
2
3# Create a logger object.
4logger = logging.getLogger(__name__)
5
6# By default the install() function installs a handler on the root logger,
7# this means that log messages from your code and log messages from the
8# libraries that you use will all show up on the terminal.
9coloredlogs.install(level='DEBUG')
10
11# Some examples.
12logger.debug("this is a debugging message")
13logger.info("this is an informational message")
14logger.warning("this is a warning message")
15logger.error("this is an error message")
16logger.critical("this is a critical message")