Hydra Colorlog

1.2.0 · active · verified Tue Apr 14

Hydra-colorlog is a plugin for the Hydra configuration framework that enables colored logging output for Hydra applications. It specifically integrates the 'colorlog' library into Hydra's internal (`hydra_logging`) and job-specific (`job_logging`) logging mechanisms, enhancing readability. The current version is 1.2.0, and its release cadence is tied to that of the main Hydra project, which sees several updates per year.

Warnings

Install

Imports

Quickstart

To enable `hydra-colorlog`, install the package and then create a Hydra configuration file (e.g., `config.yaml` in a `conf` directory) that overrides the default Hydra logging settings. This minimal example demonstrates how to set up a Hydra application and activate colored logging by explicitly specifying `colorlog` for both `hydra/job_logging` and `hydra/hydra_logging` in the defaults list.

import hydra
from omegaconf import DictConfig
import logging

log = logging.getLogger(__name__)

@hydra.main(config_path="conf", config_name="config", version_base="1.2")
def my_app(cfg: DictConfig) -> None:
    log.info("This is an info message.")
    log.warning("This is a warning message.")
    log.error("This is an error message.")
    print(f"Config: {cfg.pretty()}")

if __name__ == "__main__":
    # Create a 'conf' directory and 'config.yaml' file alongside this script.
    # In config.yaml, add:
    # defaults:
    #   - override hydra/job_logging: colorlog
    #   - override hydra/hydra_logging: colorlog
    # Example to run: python your_script_name.py
    my_app()

view raw JSON →