How to disable a log.Logger

后端 未结 6 1605
长情又很酷
长情又很酷 2020-12-23 16:35

I have some heavily instrumented code that makes use of the log package. Now it\'s come time to turn off the logging, and I can\'t determine how to turn off the

6条回答
  •  醉梦人生
    2020-12-23 17:08

    type NullWriter int
    func (NullWriter) Write([]byte) (int, error) { return 0, nil }
    
    // ...
    
    log.SetOutput(new(NullWriter))
    

提交回复
热议问题