go-tigertonic icon indicating copy to clipboard operation
go-tigertonic copied to clipboard

Customlogger

Open JimmyPettersson85 opened this issue 11 years ago • 1 comments

PR to make the (JSON)logging a little bit more versatile. This lets you log to stdout, files etc by supplying your own logger instead of having JSONLogged create one for you.

I often find myself wanting to log to both stdout and a persisted log file, using io.MultiWriter.

logWriter := io.MultiWriter(os.Stdout, myLogFileHandle)
multiLogger := log.New(logWriter, "prefix", 0)
tigertonic.JSONLogged(handler, redactor, multiLogger)

If this PR gets accepted I will create pull requests for tigertonic.Logged and tigertonic.ApacheLogged with the same changes.

JimmyPettersson85 avatar May 18 '14 01:05 JimmyPettersson85

Could we make the prefix and the logger configurable under the CustomJSONLogged constructor?

rcrowley avatar Jun 24 '14 04:06 rcrowley