DisableLogging is a test helper that disable logging (in fact it sets its level to panic). It returns a function which when called, resets it to its previous level. Its useful to be called as follows in test/benchmarks: func TestFoo(t *testing.T) { defer DisableLogging()() logging is disabled for
()
| 77 | // // logging is disabled for the whole test |
| 78 | // } |
| 79 | func DisableLogging() (reset func()) { |
| 80 | lvl := log.GetLevel() |
| 81 | log.SetLevel(log.PanicLevel) |
| 82 | return func() { log.SetLevel(lvl) } |
| 83 | } |
| 84 | |
| 85 | // LessLogging is a test helper that decreases logging (in fact it sets its |
| 86 | // level to Error). It returns a function which when called, resets it to its |
no outgoing calls