grpclog.go 560 B

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