Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured logging #46

Open
silasdavis opened this issue Jul 18, 2019 · 3 comments
Open

Structured logging #46

silasdavis opened this issue Jul 18, 2019 · 3 comments

Comments

@silasdavis
Copy link
Contributor

silasdavis commented Jul 18, 2019

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.

@vmihailenco
Copy link
Owner

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.

@sruehl
Copy link
Contributor

sruehl commented Nov 23, 2021

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

@lzap
Copy link

lzap commented Jan 2, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants