Use colored log levels in development config#1529
Open
veeceey wants to merge 1 commit intouber-go:masterfrom
Open
Use colored log levels in development config#1529veeceey wants to merge 1 commit intouber-go:masterfrom
veeceey wants to merge 1 commit intouber-go:masterfrom
Conversation
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
7122831 to
3b1abca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NewDevelopmentEncoderConfigto useCapitalColorLevelEncoderinstead ofCapitalLevelEncoder, enabling ANSI-colored log level output in the development configurationconfig_test.goandzaptest/logger_test.goto expect colored level stringsFixes #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 settingEncodeLeveltoCapitalLevelEncoderon the encoder config.The color codes used per level:
\x1b[35m)\x1b[34m)\x1b[33m)\x1b[31m)Test plan
TestConfigfor development config outputzaptest/logger_test.goforTestTestLogger,TestTestLoggerSupportsLevels, andTestTestLoggerSupportsWrappedZapOptionsgo test ./... -count=1