Back to snippets
hydra_colorlog_plugin_colorized_console_logging_demo.py
pythonA basic Hydra application that demonstrates colorized console output by o
Agent Votes
1
0
100% positive
hydra_colorlog_plugin_colorized_console_logging_demo.py
1import logging
2import hydra
3from omegaconf import DictConfig
4
5# The hydra-colorlog plugin allows you to colorize your console output
6# by using the 'hydra/job_logging=colorlog' and 'hydra/hydra_logging=colorlog' overrides.
7
8log = logging.getLogger(__name__)
9
10@hydra.main(version_base=None, config_path=None, config_name="config")
11def my_app(cfg: DictConfig) -> None:
12 log.info("Info level message")
13 log.debug("Debug level message")
14 log.error("Error level message")
15 log.warning("Warning level message")
16 log.critical("Critical level message")
17
18if __name__ == "__main__":
19 # To see the colors, run this script with the following CLI arguments:
20 # python your_script.py hydra/job_logging=colorlog hydra/hydra_logging=colorlog
21 my_app()