diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-09-05 15:31:08 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-09-05 15:46:11 +0300 |
commit | beb7fb699afbbd56efc6736f63e9c372609e3f83 (patch) | |
tree | c83924c3bc4f94e5350ad467b0da1a23239ff95e /NOTICE | |
parent | 2e3b774032b4759603cc3f668d648eecf8066953 (diff) |
grpc/backchannel: Simplify logging with yamux
We're currently passing in an `io.WriteCloser()` to Yamux that is then
being used as logger. This has the consequence that we're quite tied to
the actual implementation of the logger because `WriterLevel()` is not
something that's typically available in other logging libraries. But
more importantly, it means that all log messages are now written at the
error level, which isn't quite what we want.
The current setup is actually a limitation of the Yamux package itself:
we can either pass in a log writer, or a `log.Logger`. We don't really
want either though. This limitation has been fixed upstream via 13a7bc0
(Fix hashicorp/yamux#72, abstract logger into interface, 2019-04-15),
which converts starts to accept an interface instead of a `log.Logger`.
The library didn't release a new version since then though, and given
that this is change has been implemented four years ago, it seems quite
unlikely that a new release will be created soonish. That being said
though, upgrading to that unstable version should be fine as the only
change between our current v0.1.1 and that commit is the change to use
that logger interface.
Let's upgrade Yamux to the version including this change and refactor
our code to pass the `logrus.FieldLogger` directly instead of passing
an `io.Writer`.
Diffstat (limited to 'NOTICE')
-rw-r--r-- | NOTICE | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -16028,7 +16028,6 @@ package yamux import ( "fmt" "io" - "log" "os" "time" ) @@ -16076,7 +16075,7 @@ type Config struct { // Logger is used to pass in the logger to be used. Either Logger or // LogOutput can be set, not both. - Logger *log.Logger + Logger Logger } // DefaultConfig is used to return a default configuration @@ -16176,7 +16175,7 @@ type Session struct { config *Config // logger is used for our logs - logger *log.Logger + logger Logger // conn is the underlying connection conn io.ReadWriteCloser @@ -19111,6 +19110,13 @@ import ( "time" ) +// Logger is a abstract of *log.Logger +type Logger interface { + Print(v ...interface{}) + Printf(format string, v ...interface{}) + Println(v ...interface{}) +} + var ( timerPool = &sync.Pool{ New: func() interface{} { |