-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Custom logger doesn't work due to usage of c.Logger.SetOutput
#117
Comments
Hi @develar Thank you for reporting this. Olric shares the same logging semantics with hashicorp/memberlist. I have just fixed the problem and tried to implement a new logger with zap. It produces the following output. It looks a bit ugly and includes some useless portions. You may need to implement a wrapper to parse the messages before writing to I released v0.3.12 which includes fixes for #117 and #116.
|
Thanks for a quick fix.
c.Logger = log.New(&loggerWriter{logger}, "" /* prefix */, 0 /* flags */) func (t *loggerWriter) Write(message []byte) (int, error) {
message = bytes.TrimSpace(message)
if len(message) < 2 {
t.logger.Info(string(message))
} else {
switch message[1] {
case 'I':
t.logger.Info(string(message[7:]))
case 'W':
t.logger.Warn(string(message[7:]))
case 'D':
t.logger.Debug(string(message[8:]))
default:
t.logger.Info(string(message))
}
}
return len(message), nil
} Works for me:
|
cacheConfig.Logger = zap.NewStdLog(logger)
doesn't work. You cannot use own logger.The issue: Olric calls
c.Logger.SetOutput(filter)
and it means that Olric ignore passed custom logger output, becausec.Logger.SetOutput
overwrites it. As result, despite setting custom logger, standard flog is used:If the custom logger is set,
c.LogLevel
should be ignored, and passedLogger
is used as-is.The text was updated successfully, but these errors were encountered: