grpclog.go 627 B

1234567891011121314151617181920
  1. package main
  2. import (
  3. "context"
  4. "github.com/containerd/containerd/log"
  5. "github.com/sirupsen/logrus"
  6. "google.golang.org/grpc/grpclog"
  7. )
  8. // grpc's default logger is *very* noisy and uses "info" and even "warn" level logging for mostly useless messages.
  9. // This function configures the grpc logger to step down the severity of all messages.
  10. //
  11. // info => trace
  12. // warn => debug
  13. // error => warn
  14. func configureGRPCLog() {
  15. l := log.G(context.TODO()).WithField("library", "grpc")
  16. grpclog.SetLoggerV2(grpclog.NewLoggerV2(l.WriterLevel(logrus.TraceLevel), l.WriterLevel(logrus.DebugLevel), l.WriterLevel(logrus.WarnLevel)))
  17. }