MCPcopy
hub / github.com/rs/zerolog / setup

Function setup

log/log_example_test.go:21–33  ·  view source on GitHub ↗

setup would normally be an init() function, however, there seems to be something awry with the testing framework when we set the global Logger from an init()

()

Source from the content-addressed store, hash-verified

19// to be something awry with the testing framework when we set the
20// global Logger from an init()
21func setup() {
22 // UNIX Time is faster and smaller than most timestamps
23 // If you set zerolog.TimeFieldFormat to an empty string,
24 // logs will write with UNIX time
25 zerolog.TimeFieldFormat = ""
26 // In order to always output a static time to stdout for these
27 // examples to pass, we need to override zerolog.TimestampFunc
28 // and log.Logger globals -- you would not normally need to do this
29 zerolog.TimestampFunc = func() time.Time {
30 return time.Date(2008, 1, 8, 17, 5, 05, 0, time.UTC)
31 }
32 log.Logger = zerolog.New(os.Stdout).With().Timestamp().Logger()
33}
34
35// Simple logging example using the Print function in the log package
36// Note that both Print and Printf are at the debug log level by default

Callers 15

ExamplePrintFunction · 0.85
ExamplePrintfFunction · 0.85
ExampleLogFunction · 0.85
ExampleErrFunction · 0.85
ExampleTraceFunction · 0.85
ExampleDebugFunction · 0.85
ExampleInfoFunction · 0.85
ExampleWarnFunction · 0.85
ExampleErrorFunction · 0.85
ExampleFatalFunction · 0.85
ExamplePanicFunction · 0.85
ExampleFunction · 0.85

Calls 4

NewFunction · 0.92
LoggerMethod · 0.80
WithMethod · 0.80
TimestampMethod · 0.45

Tested by

no test coverage detected