pub fn should_colorize() -> boolExpand description
Determine whether console log output should include ANSI color codes.
Priority order (highest to lowest):
NO_COLORenv var set → no color (https://no-color.org/ convention)FORCE_COLORenv var set → force color (useful in Docker/CI)stderris a TTY → color (interactive terminal)stderris not a TTY → no color (piped/redirected)
§CUSTOMIZE: Docker containers
Docker containers often do NOT have a TTY attached to stderr, which would
disable color by rule 4. But docker compose logs renders ANSI codes
correctly, so operators benefit from colors.
Set FORCE_COLOR=1 in your docker-compose.yml or Dockerfile:
environment:
FORCE_COLOR: "1"§CUSTOMIZE: CI/CD pipelines
Most CI systems (GitHub Actions, GitLab CI) support ANSI codes.
Set FORCE_COLOR=1 in your CI environment variables to enable color logs.