...

Source file src/github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/grpclogger.go

Documentation: github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus

     1  // Copyright 2017 Michal Witkowski. All Rights Reserved.
     2  // See LICENSE for licensing terms.
     3  
     4  package grpc_logrus
     5  
     6  import (
     7  	"github.com/sirupsen/logrus"
     8  	"google.golang.org/grpc/grpclog"
     9  )
    10  
    11  // ReplaceGrpcLogger sets the given logrus.Logger as a gRPC-level logger.
    12  // This should be called *before* any other initialization, preferably from init() functions.
    13  func ReplaceGrpcLogger(logger *logrus.Entry) {
    14  	grpclog.SetLoggerV2(&logrusGrpcLoggerV2{
    15  		logger.WithField("system", SystemField),
    16  	})
    17  }
    18  
    19  type logrusGrpcLoggerV2 struct {
    20  	*logrus.Entry
    21  }
    22  
    23  func (l *logrusGrpcLoggerV2) V(level int) bool {
    24  	return l.Logger.IsLevelEnabled(logrus.Level(level))
    25  }
    26  

View as plain text