taskq icon indicating copy to clipboard operation
taskq copied to clipboard

Structured logging

Open silasdavis opened this issue 6 years ago • 3 comments

Many of the log statements have a semi-structured format with key=value substrings. It is useful operationally to have distinct key-values for downstream loggers like elasticsearch, logstash,etc.

I propose we swap out the Go std logger for an interface like:

https://github.com/go-kit/kit/blob/master/log/log.go#L11

or

https://github.com/inconshreveable/log15/blob/master/handler.go#L19

And use one of those libraries to handle the logging. Both work well. The former has simplest possible interface, the latter a little bit more structure, but both essentially transmit the same information.

I also personally much prefer to not share a global logging instance and pass it down the stack through options, but I appreciate it is a matter of taste. I think we could optionally set it on the factory and have it passed down from there.

Will submit PR if you agree.

silasdavis avatar Jul 18 '19 16:07 silasdavis

Let's try Logger from go-kit - it looks very simple. I guess we don't need to pull whole go-kit just for the interface and can copy paste only interface with the reference to go-kit somewhere.

vmihailenco avatar Jul 19 '19 08:07 vmihailenco

stumbled over that: https://github.com/go-logr/logr might be the best option as it's pluggable to a lot of logging framework

sruehl avatar Nov 23 '21 16:11 sruehl

Go now has the new slog experimental package: https://pkg.go.dev/golang.org/x/exp/slog

lzap avatar Jan 02 '23 14:01 lzap