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

Function ExampleErr

log/log_example_test.go:61–69  ·  view source on GitHub ↗

Example of a conditional level based on the presence of an error.

()

Source from the content-addressed store, hash-verified

59
60// Example of a conditional level based on the presence of an error.
61func ExampleErr() {
62 setup()
63 err := errors.New("some error")
64 log.Err(err).Msg("hello world")
65 log.Err(nil).Msg("hello world")
66
67 // Output: {"level":"error","error":"some error","time":1199811905,"message":"hello world"}
68 // {"level":"info","time":1199811905,"message":"hello world"}
69}
70
71// Example of a log at a particular "level" (in this case, "trace")
72func ExampleTrace() {

Callers

nothing calls this directly

Calls 3

ErrFunction · 0.92
setupFunction · 0.85
MsgMethod · 0.80

Tested by

no test coverage detected