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

Add structured logging #53

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

nikolaik
Copy link

@nikolaik nikolaik commented Oct 12, 2022

Hi there, this adds structured logging using zap. You can change formats using --log_format Valid formats are json and plain.

Example run

$ go run main.go --github_token asdf --log_format=plain
2022-10-14T13:08:39.895+0200	INFO	metrics/metrics.go:85	authenticating with Github Token
2022-10-14T13:08:39.895+0200	INFO	server/server.go:33	exporter listening on 0.0.0.0:9999

$ go run main.go --github_token asdf
{"level":"info","ts":1665745733.755991,"caller":"metrics/metrics.go:85","msg":"authenticating with Github Token"}
{"level":"info","ts":1665745733.756206,"caller":"server/server.go:33","msg":"exporter listening on 0.0.0.0:9999"}

Open to changing anything about the implementation. For instance, does it make sense to be able to toggle structured/unstructured using a flag?

Note that pkg/metrics/get_runners_enterprise_from_github.go had CRLF line endings, so i converted those to LF.

@nikolaik nikolaik marked this pull request as ready for review October 14, 2022 11:11
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

Successfully merging this pull request may close these issues.

1 participant