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()
()
| 19 | // to be something awry with the testing framework when we set the |
| 20 | // global Logger from an init() |
| 21 | func 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 |
no test coverage detected