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

Function TestLoggerV2Severity

grpclog/internal/loggerv2_test.go:103–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestLoggerV2Severity(t *testing.T) {
104 buffers := []*bytes.Buffer{new(bytes.Buffer), new(bytes.Buffer), new(bytes.Buffer)}
105 l := NewLoggerV2(buffers[infoLog], buffers[warningLog], buffers[errorLog], LoggerV2Config{})
106
107 l.Info(severityName[infoLog])
108 l.Warning(severityName[warningLog])
109 l.Error(severityName[errorLog])
110
111 for i := 0; i < fatalLog; i++ {
112 buf := buffers[i]
113 // The content of info buffer should be something like:
114 // INFO: 2017/04/07 14:55:42 INFO
115 // WARNING: 2017/04/07 14:55:42 WARNING
116 // ERROR: 2017/04/07 14:55:42 ERROR
117 for j := i; j < fatalLog; j++ {
118 b, err := buf.ReadBytes('\n')
119 if err != nil {
120 t.Fatalf("level %d: %v", j, err)
121 }
122 if err := checkLogForSeverity(j, b); err != nil {
123 t.Fatal(err)
124 }
125 }
126 }
127}
128
129// TestLoggerV2PrintFuncDiscardOnlyInfo ensures that logs at the INFO level are
130// discarded when set to io.Discard, while logs at other levels (WARN, ERROR)

Callers

nothing calls this directly

Calls 7

InfoMethod · 0.95
WarningMethod · 0.95
ErrorMethod · 0.95
checkLogForSeverityFunction · 0.85
NewLoggerV2Function · 0.70
FatalfMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected