hashicorp/yamux

Config should take a Logger interface

lthibault opened this issue · 3 comments

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

+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.

Agree, but this is incompatible update.

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