How to disable a log.Logger

后端 未结 6 1623
长情又很酷
长情又很酷 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:12

    No reason to create your own type for a common io.Writer when one exists in the io/ioutil package.

    import (
        "log"
        "io/ioutil"
    )
    
    func init() {
        log.SetOutput(ioutil.Discard)
    }
    

提交回复
热议问题