MCPcopy
hub / github.com/grpc/grpc-go / newLoggerV2

Function newLoggerV2

grpclog/loggerv2.go:60–87  ·  view source on GitHub ↗

newLoggerV2 creates a loggerV2 to be used as default logger. All logs are written to stderr.

()

Source from the content-addressed store, hash-verified

58// newLoggerV2 creates a loggerV2 to be used as default logger.
59// All logs are written to stderr.
60func newLoggerV2() LoggerV2 {
61 errorW := io.Discard
62 warningW := io.Discard
63 infoW := io.Discard
64
65 logLevel := os.Getenv("GRPC_GO_LOG_SEVERITY_LEVEL")
66 switch logLevel {
67 case "", "ERROR", "error": // If env is unset, set level to ERROR.
68 errorW = os.Stderr
69 case "WARNING", "warning":
70 warningW = os.Stderr
71 case "INFO", "info":
72 infoW = os.Stderr
73 }
74
75 var v int
76 vLevel := os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL")
77 if vl, err := strconv.Atoi(vLevel); err == nil {
78 v = vl
79 }
80
81 jsonFormat := strings.EqualFold(os.Getenv("GRPC_GO_LOG_FORMATTER"), "json")
82
83 return internal.NewLoggerV2(infoW, warningW, errorW, internal.LoggerV2Config{
84 Verbosity: v,
85 FormatJSON: jsonFormat,
86 })
87}
88
89// DepthLoggerV2 logs at a specified call frame. If a LoggerV2 also implements
90// DepthLoggerV2, the below functions will be called with the appropriate stack

Callers 1

initFunction · 0.85

Calls 1

NewLoggerV2Function · 0.92

Tested by

no test coverage detected