MCPcopy
hub / github.com/safing/portmaster / TestLogging

Function TestLogging

base/log/logging_test.go:16–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14}
15
16func TestLogging(t *testing.T) {
17 t.Parallel()
18
19 // skip
20 if testing.Short() {
21 t.Skip()
22 }
23
24 // set levels (static random)
25 SetLogLevel(WarningLevel)
26 SetLogLevel(InfoLevel)
27 SetLogLevel(ErrorLevel)
28 SetLogLevel(DebugLevel)
29 SetLogLevel(CriticalLevel)
30 SetLogLevel(TraceLevel)
31
32 // log
33 Trace("Trace")
34 Debug("Debug")
35 Info("Info")
36 Warning("Warning")
37 Error("Error")
38 Critical("Critical")
39
40 // logf
41 Tracef("Trace %s", "f")
42 Debugf("Debug %s", "f")
43 Infof("Info %s", "f")
44 Warningf("Warning %s", "f")
45 Errorf("Error %s", "f")
46 Criticalf("Critical %s", "f")
47
48 // play with levels
49 SetLogLevel(CriticalLevel)
50 Warning("Warning")
51 SetLogLevel(TraceLevel)
52
53 // log invalid level
54 log(0xFF, "msg", nil)
55
56 // wait logs to be written
57 time.Sleep(1 * time.Millisecond)
58
59 // do not really shut down, we may need logging for other tests
60 // ShutdownLogging()
61}

Callers

nothing calls this directly

Calls 14

SetLogLevelFunction · 0.85
TraceFunction · 0.85
DebugFunction · 0.85
WarningFunction · 0.85
CriticalFunction · 0.85
TracefFunction · 0.85
DebugfFunction · 0.85
InfofFunction · 0.85
WarningfFunction · 0.85
ErrorfFunction · 0.85
CriticalfFunction · 0.85
logFunction · 0.85

Tested by

no test coverage detected