Skip to content

Use colored log levels in development config#1529

Open
veeceey wants to merge 1 commit intouber-go:masterfrom
veeceey:fix/issue-489-colored-console
Open

Use colored log levels in development config#1529
veeceey wants to merge 1 commit intouber-go:masterfrom
veeceey:fix/issue-489-colored-console

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 20, 2026

Summary

  • Changes NewDevelopmentEncoderConfig to use CapitalColorLevelEncoder instead of CapitalLevelEncoder, enabling ANSI-colored log level output in the development configuration
  • Log levels are now visually distinct in terminal output: Debug (magenta), Info (blue), Warn (yellow), Error/DPanic/Panic/Fatal (red)
  • Updates tests in config_test.go and zaptest/logger_test.go to expect colored level strings

Fixes #489

Details

The development configuration is designed for human-readable console output. By using the already-existing CapitalColorLevelEncoder (which was available but not used by default), log lines become much easier to scan visually. Users who prefer uncolored output can still override this by setting EncodeLevel to CapitalLevelEncoder on the encoder config.

The color codes used per level:

  • DEBUG: Magenta (\x1b[35m)
  • INFO: Blue (\x1b[34m)
  • WARN: Yellow (\x1b[33m)
  • ERROR/DPANIC/PANIC/FATAL: Red (\x1b[31m)

Test plan

  • Updated regex expectations in TestConfig for development config output
  • Updated string expectations in zaptest/logger_test.go for TestTestLogger, TestTestLoggerSupportsLevels, and TestTestLoggerSupportsWrappedZapOptions
  • All tests pass: go test ./... -count=1

@CLAassistant
Copy link

CLAassistant commented Feb 20, 2026

CLA assistant check
All committers have signed the CLA.

Change NewDevelopmentEncoderConfig to use CapitalColorLevelEncoder
instead of CapitalLevelEncoder, so that log levels are colored when
using the development configuration. This makes it easier to visually
distinguish between different log levels in terminal output.

Fixes uber-go#489
@veeceey veeceey force-pushed the fix/issue-489-colored-console branch from 7122831 to 3b1abca Compare February 23, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Dev: Colored console output

2 participants