goagain icon indicating copy to clipboard operation
goagain copied to clipboard

Allow logging to be overridden

Open robstrong opened this issue 10 years ago • 2 comments

I agree with #2 and #3 that logging should not forced upon users of this library. But I also agree with @rcrowley that the logging is useful and needed. This PR doesn't change the default logging functionality but adds a Logger var on the package that can be set to override where log messages go.

This can be useful for applications that already have a logger setup and want the goagain logs to go to the same place. You just set

myLogger := log.New(myWriter, "err: ", log.LstdFlags)
goagain.Logger = myLogger

Or if you wanted to disable logging altogether, you can set

goagain.Logger = nil

robstrong avatar Apr 22 '15 13:04 robstrong

@rcrowley Any thoughts on this?

robstrong avatar May 14 '15 00:05 robstrong

Would love it if this could be merged. The current approach makes things difficult for applications that use specially formatted logs parsed by tools like logstash.

This is similar to a hardcoded logger that was changed to be configurable in the standard library's httputil/reverseproxy: https://github.com/golang/go/commit/1a1d43239e42184694d0207ffad9bbb77d8e8f76

brasic avatar Oct 13 '15 21:10 brasic