Documentation ¶
Overview ¶
Package grpclog defines logging for grpc.
All logs in transport and grpclb packages only go to verbose level 2. All logs in other packages in grpc are logged in spite of the verbosity level.
In the default logger, severity level can be set by environment variable GRPC_GO_LOG_SEVERITY_LEVEL, verbosity level can be set by GRPC_GO_LOG_VERBOSITY_LEVEL.
Index ¶
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Errorln(args ...any)
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func Fatalln(args ...any)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func Infoln(args ...any)
- func Print(args ...any)deprecated
- func Printf(format string, args ...any)deprecated
- func Println(args ...any)deprecated
- func SetLogger(l Logger)deprecated
- func SetLoggerV2(l LoggerV2)
- func V(l int) bool
- func Warning(args ...any)
- func Warningf(format string, args ...any)
- func Warningln(args ...any)
- type DepthLoggerV2
- type Loggerdeprecated
- type LoggerV2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶ added in v1.5.0
Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
func Errorln ¶ added in v1.5.0
func Errorln(args ...any)
Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println.
func Fatal ¶
func Fatal(args ...any)
Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print. It calls os.Exit() with exit code 1.
func Fatalf ¶
Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf. It calls os.Exit() with exit code 1.
func Fatalln ¶
func Fatalln(args ...any)
Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println. It calle os.Exit()) with exit code 1.
func Infof ¶ added in v1.5.0
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
func Infoln ¶ added in v1.5.0
func Infoln(args ...any)
Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println.
func SetLoggerV2 ¶ added in v1.5.0
func SetLoggerV2(l LoggerV2)
SetLoggerV2 sets logger that is used in grpc to a V2 logger. Not mutex-protected, should be called before any gRPC functions.
func V ¶ added in v1.5.0
V reports whether verbosity level l is at least the requested verbose level.
Types ¶
type DepthLoggerV2 ¶ added in v1.28.0
type DepthLoggerV2 interface { LoggerV2 // InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println. InfoDepth(depth int, args ...any) // WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println. WarningDepth(depth int, args ...any) // ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println. ErrorDepth(depth int, args ...any) // FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println. FatalDepth(depth int, args ...any) }
DepthLoggerV2 logs at a specified call frame. If a LoggerV2 also implements DepthLoggerV2, the below functions will be called with the appropriate stack depth set for trivial functions the logger may ignore.
Experimental ¶
Notice: This type is EXPERIMENTAL and may be changed or removed in a later release.
func Component ¶ added in v1.31.0
func Component(componentName string) DepthLoggerV2
Component creates a new component and returns it for logging. If a component with the name already exists, nothing will be created and it will be returned. SetLoggerV2 will panic if it is called with a logger created by Component.
type LoggerV2 ¶ added in v1.5.0
type LoggerV2 interface { // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. Info(args ...any) // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. Infoln(args ...any) // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. Infof(format string, args ...any) // Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. Warning(args ...any) // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. Warningln(args ...any) // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. Warningf(format string, args ...any) // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. Error(args ...any) // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. Errorln(args ...any) // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. Errorf(format string, args ...any) // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatal(args ...any) // Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatalln(args ...any) // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatalf(format string, args ...any) // V reports whether verbosity level l is at least the requested verbose level. V(l int) bool }
LoggerV2 does underlying logging work for grpclog.
func NewLoggerV2 ¶ added in v1.5.0
NewLoggerV2 creates a loggerV2 with the provided writers. Fatal logs will be written to errorW, warningW, infoW, followed by exit(1). Error logs will be written to errorW, warningW and infoW. Warning logs will be written to warningW and infoW. Info logs will be written to infoW.