-
Notifications
You must be signed in to change notification settings - Fork 18
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
Logging With Zap Logger #160
Comments
Hi @reesmanp , can you explain a bit more about what difficulty you are encountering - specifically? Is there some reason Zap cannot be used with the BaseLoggers interface? |
@cwaldren-ld thanks for responding. There are two main issues. One is easy enough to add a wrapper around and implement myself, that is the Debug(values ...interface{}) where as zap has: Debug(msg string, fields ...Field) |
We would really appreciate this too. I don't understand how |
Hi @AFMiziara and @reesmanp , I think you might be running into friction because the Our documentation says:
It is expected to behave like Go's standard For example, You can forward this to Zap. Example: func (m *myBaseLogger) Println(args ...interface{}) {
m.zapLogger.Sugar().Info(args...)
} Or, you could use structured logging and have a field for "launchdarkly message" or similar. One issue with the example I gave is that all logs would then be logged at Zap's If that's unacceptable, you could use // somewhere:
loggers.SetBaseLoggerForLevel(ldlog.Info, newZapInfoLogger(ldlog.Info))
// zapInfoLogger holds a reference to a zap logger, and an ldlog.Level so it can know what to strip
// out of the message
func (m *zapInfoLogger) Println(args ...interface{}) {
m.zap.Info(strings.TrimPrefix(fmt.Sprintf(args...), m.level.String()+":")
}
// you could instead convert the ldlog.Level into a zapcore.Level and use one of Zap's functions
// that accepts a level. |
@cwaldren-ld ok, I think this works. Definitely not an ideal case but workable. Is this something you could add to the documentation? |
This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days. |
Would adopting Current workaround I use is:
Finally, the client can be configured like:
|
Thank you for sharing that, @jsok. I think Our version policy is to support the last two releases of Go, so we could make this change (we generally try not to raise the minimum version unless it's required by useful feature - which we might consider Filed internally as SDK-706. |
Zap is a popular logging library for golang which I am currently using. However, the logging interface launch darkly uses is at odds with zap and I cannot utilize the same logger I am using for the rest of the application with launch darkly. I think it would be ideal to support zap here.
The text was updated successfully, but these errors were encountered: