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:
commit
1b263035af
2 changed files with 18 additions and 0 deletions
|
@ -88,6 +88,7 @@ func main() {
|
||||||
_, stdout, stderr := term.StdStreams()
|
_, stdout, stderr := term.StdStreams()
|
||||||
|
|
||||||
initLogging(stdout, stderr)
|
initLogging(stdout, stderr)
|
||||||
|
configureGRPCLog()
|
||||||
|
|
||||||
onError := func(err error) {
|
onError := func(err error) {
|
||||||
fmt.Fprintf(stderr, "%s\n", err)
|
fmt.Fprintf(stderr, "%s\n", err)
|
||||||
|
|
17
cmd/dockerd/grpclog.go
Normal file
17
cmd/dockerd/grpclog.go
Normal 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)))
|
||||||
|
}
|
Loading…
Reference in a new issue