I start to use the zap log lib for my go project. I want to print the different color to tty console dependent on the log level.
I find the zap/internal/color
can display different color for string, But I want to change the log level with different color.
I also want to write the log to some log files with different log level.
How to init and config the zap log?
Just met the same issue, and here are some code snippets for enable colors:
config := zap.NewDevelopmentConfig()
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
logger, _ := config.Build()
logger.Info("Now logs should be colored")
reference: https://github.com/uber-go/zap/pull/307