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

Use go-kit log.NewStdlibAdapter instead of our own adapter #587

Merged
merged 1 commit into from Apr 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 2 additions & 16 deletions speaker/main.go
Expand Up @@ -117,7 +117,8 @@ func main() {
mconfig.BindPort = mlport
mconfig.AdvertisePort = mlport
}
mconfig.Logger = golog.New(goKitLogWriter{logger}, "", golog.Lshortfile)
loggerout := gokitlog.NewStdlibAdapter(gokitlog.With(logger, "component", "MemberList"))
mconfig.Logger = golog.New(loggerout, "", golog.Lshortfile)
if *mlSecret != "" {
sha := sha256.New()
mconfig.SecretKey = sha.Sum([]byte(*mlSecret))[:16]
Expand Down Expand Up @@ -203,21 +204,6 @@ func watchMemberListEvents(logger gokitlog.Logger, eventCh chan memberlist.NodeE
}
}

type goKitLogWriter struct {
gokitlog.Logger
}

func (l goKitLogWriter) Write(p []byte) (int, error) {
if len(p) > 1 {
// last char is '\n'
err := l.Log("component", "MemberList", "msg", string(p[:len(p)-1]))
if err != nil {
return 0, err
}
}
return len(p), nil
}

type controller struct {
myNode string

Expand Down