Skip to content

Commit b6d97fa

Browse files
Improve zap grpc logger documentation on verbosity levels (#456)
1 parent b7b1ffc commit b6d97fa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

logging/zap/grpclogger.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ func (l *zapGrpcLogger) Println(args ...interface{}) {
4747
l.logger.Info(fmt.Sprint(args...))
4848
}
4949

50-
// ReplaceGrpcLoggerV2 replaces the grpc_log.LoggerV2 with the provided logger.
51-
// It should be called before any gRPC functions.
50+
// ReplaceGrpcLoggerV2 replaces the grpclog.LoggerV2 with the provided logger.
51+
// It should be called before any gRPC functions. Logging verbosity defaults to info level.
52+
// To adjust gRPC logging verbosity, see ReplaceGrpcLoggerV2WithVerbosity.
5253
func ReplaceGrpcLoggerV2(logger *zap.Logger) {
5354
ReplaceGrpcLoggerV2WithVerbosity(logger, 0)
5455
}
5556

56-
// ReplaceGrpcLoggerV2WithVerbosity replaces the grpc_.LoggerV2 with the provided logger and verbosity.
57+
// ReplaceGrpcLoggerV2WithVerbosity replaces the grpclog.Logger with the provided logger and verbosity.
5758
// It should be called before any gRPC functions.
59+
// verbosity correlates to grpclogs verbosity levels. A higher verbosity value results in less logging.
5860
func ReplaceGrpcLoggerV2WithVerbosity(logger *zap.Logger, verbosity int) {
5961
zgl := &zapGrpcLoggerV2{
6062
logger: logger.With(SystemField, zap.Bool("grpc_log", true)).WithOptions(zap.AddCallerSkip(2)),
@@ -63,7 +65,7 @@ func ReplaceGrpcLoggerV2WithVerbosity(logger *zap.Logger, verbosity int) {
6365
grpclog.SetLoggerV2(zgl)
6466
}
6567

66-
// SetGrpcLoggerV2 replaces the grpc_log.LoggerV2 with the provided logger.
68+
// SetGrpcLoggerV2 replaces the grpc_log.Logger with the provided logger.
6769
// It can be used even when grpc infrastructure was initialized.
6870
func SetGrpcLoggerV2(settable grpc_logsettable.SettableLoggerV2, logger *zap.Logger) {
6971
SetGrpcLoggerV2WithVerbosity(settable, logger, 0)

0 commit comments

Comments
 (0)