hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.25k stars 236 forks source link

Config should take a Logger interface #72

Closed lthibault closed 2 years ago

lthibault commented 6 years ago

At present, yamux.Config.Logger is a pointer to a concrete struct. This makes it impossible to use popular libraries such as https://github.com/sirupsen/logrus.

Fortunately, most logging libraries implicitly satisfy the following interface:

type Logger interface {
    Fatal(v ...interface{})
    Fatalf(format string, v ...interface{})
    Fatalln(v ...interface{})
    Panic(v ...interface{})
    Panicf(format string, v ...interface{})
    Panicln(v ...interface{})
    Prefix() string
    Print(v ...interface{})
    Printf(format string, v ...interface{})
    Println(v ...interface{})
}

Config should take an interface like the one above in lieu of *log.Logger.

nnam commented 5 years ago

+1 yamux.Config.LogOutput takes an io.Writer and can be used as a workaround, but it seems to make more sense to have yamug.Config.Logger take an interface.

gonejack commented 4 years ago

Agree, but this is incompatible update.

lthibault commented 4 years ago

@gonejack are you sure? People using a *log.Logger should be able to assign it just as before, since it matches the new interface.