Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows color #714

Open
ghost opened this issue May 16, 2019 · 1 comment
Open

Windows color #714

ghost opened this issue May 16, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented May 16, 2019

Using this file:

package main
import (
   "go.uber.org/zap"
   "go.uber.org/zap/zapcore"
)
func main() {
   config := zap.NewDevelopmentConfig()
   config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
   logger, _ := config.Build()
   logger.Info("aaaaa bbbbb")
}

I get this result:

2019-05-15T19:25:40.817-0500     [34mINFO [0m   Desktop/log.go:10       aaaaa bbbbb
@ghost ghost mentioned this issue May 16, 2019
@ghost
Copy link
Author

ghost commented Jun 23, 2019

Workaround:

package main
import (
   "github.com/mattn/go-colorable"
   "go.uber.org/zap"
   "go.uber.org/zap/zapcore"
)
func main() {
   aa := zap.NewDevelopmentEncoderConfig()
   aa.EncodeLevel = zapcore.CapitalColorLevelEncoder
   bb := zap.New(zapcore.NewCore(
      zapcore.NewConsoleEncoder(aa),
      zapcore.AddSync(colorable.NewColorableStdout()),
      zapcore.DebugLevel,
   ))
   bb.Warn("cc")
}

Or:

package main
import "github.com/labstack/gommon/log"
func main() {
   log.EnableColor()
   log.Info("aaaaa bbbbb")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

0 participants