MCPcopy
hub / github.com/op/go-logging / InitForTesting

Function InitForTesting

memory.go:20–33  ·  view source on GitHub ↗

TODO pick one of the memory backends and stick with it or share interface. InitForTesting is a convenient method when using logging in a test. Once called, the time will be frozen to January 1, 1970 UTC.

(level Level)

Source from the content-addressed store, hash-verified

18// InitForTesting is a convenient method when using logging in a test. Once
19// called, the time will be frozen to January 1, 1970 UTC.
20func InitForTesting(level Level) *MemoryBackend {
21 Reset()
22
23 memoryBackend := NewMemoryBackend(10240)
24
25 leveledBackend := AddModuleLevel(memoryBackend)
26 leveledBackend.SetLevel(level, "")
27 SetBackend(leveledBackend)
28
29 timeNow = func() time.Time {
30 return time.Unix(0, 0).UTC()
31 }
32 return memoryBackend
33}
34
35// Node is a record node pointing to an optional next node.
36type node struct {

Callers 11

TestFormatFunction · 0.85
TestRealFuncFormatFunction · 0.85
TestStructFuncFormatFunction · 0.85
TestVarFuncFormatFunction · 0.85
TestBackendFormatterFunction · 0.85
BenchmarkStringFormatterFunction · 0.85
TestSequenceNoOverflowFunction · 0.85
TestRedactFunction · 0.85
TestRedactfFunction · 0.85
TestPrivateBackendFunction · 0.85
ExampleFunction · 0.85

Calls 5

ResetFunction · 0.85
NewMemoryBackendFunction · 0.85
AddModuleLevelFunction · 0.85
SetBackendFunction · 0.85
SetLevelMethod · 0.65

Tested by 11

TestFormatFunction · 0.68
TestRealFuncFormatFunction · 0.68
TestStructFuncFormatFunction · 0.68
TestVarFuncFormatFunction · 0.68
TestBackendFormatterFunction · 0.68
BenchmarkStringFormatterFunction · 0.68
TestSequenceNoOverflowFunction · 0.68
TestRedactFunction · 0.68
TestRedactfFunction · 0.68
TestPrivateBackendFunction · 0.68
ExampleFunction · 0.68