Example of a conditional level based on the presence of an error.
()
| 59 | |
| 60 | // Example of a conditional level based on the presence of an error. |
| 61 | func 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") |
| 72 | func ExampleTrace() { |