Merge pull request #45374 from thaJeztah/23.0_backport_stfu_grpc

[23.0 backport] Silence GRPC logs unless our log level is debug
This commit is contained in:
Sebastiaan van Stijn 2023-04-26 15:21:47 +02:00 committed by GitHub
commit 1b263035af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -88,6 +88,7 @@ func main() {
_, stdout, stderr := term.StdStreams()
initLogging(stdout, stderr)
configureGRPCLog()
onError := func(err error) {
fmt.Fprintf(stderr, "%s\n", err)

17
cmd/dockerd/grpclog.go Normal file
View file

@ -0,0 +1,17 @@
package main
import (
"github.com/sirupsen/logrus"
"google.golang.org/grpc/grpclog"
)
// grpc's default logger is *very* noisy and uses "info" and even "warn" level logging for mostly useless messages.
// This function configures the grpc logger to step down the severity of all messages.
//
// info => trace
// warn => debug
// error => warn
func configureGRPCLog() {
l := logrus.WithField("library", "grpc")
grpclog.SetLoggerV2(grpclog.NewLoggerV2(l.WriterLevel(logrus.TraceLevel), l.WriterLevel(logrus.DebugLevel), l.WriterLevel(logrus.WarnLevel)))
}