Closed johanfleury closed 3 years ago
This PR change logging framework from github.com/prometheus/common/log to github.com/prometheus/common/promlog as the former was removed in v0.27.0.
github.com/prometheus/common/log
github.com/prometheus/common/promlog
This changes quite a few things, especially the log format:
$ go run ssl_exporter.go INFO[0000] Starting ssl_exporter (version=, branch=, revision=) source="ssl_exporter.go:130" INFO[0000] Build context (go=go1.15.13, user=, date=) source="ssl_exporter.go:131" INFO[0000] Listening on :9219 source="ssl_exporter.go:148" ^Csignal: interrupt $ go run ssl_exporter.go ts=2021-06-10T18:20:51.579Z caller=log.go:168 level=info msg="Starting ssl_exporter (version=, branch=, revision=)" ts=2021-06-10T18:20:51.579Z caller=log.go:168 level=info msg="Build context (go=go1.15.13, user=, date=)" ts=2021-06-10T18:20:51.579Z caller=log.go:168 level=info msg="Listening on :9219" ^Csignal: interrupt $ go run ssl_exporter.go --log.format=json {"caller":"log.go:168","level":"info","msg":"Starting ssl_exporter (version=, branch=, revision=)","ts":"2021-06-10T20:11:19.128Z"} {"caller":"log.go:168","level":"info","msg":"Build context (go=go1.15.13, user=, date=)","ts":"2021-06-10T20:11:19.129Z"} {"caller":"log.go:168","level":"info","msg":"Listening on :9219","ts":"2021-06-10T20:11:19.129Z"} ^Csignal: interrupt
Sending a log to a specific level requires to use the go-kit/log/level module with the following syntax: level.<Level>(logger).Log(...).
go-kit/log/level
level.<Level>(logger).Log(...)
go-kit/log provides structured logs and I tried to use existing keys that were already used.
go-kit/log
Thanks for the reviewing so quickly :) I think fixed what you asked.
I created a new file (prober/test.go) to put the newTestLogger function, let me know if that’s ok.
prober/test.go
newTestLogger
This PR change logging framework from
github.com/prometheus/common/log
togithub.com/prometheus/common/promlog
as the former was removed in v0.27.0.This changes quite a few things, especially the log format:
Sending a log to a specific level requires to use the
go-kit/log/level
module with the following syntax:level.<Level>(logger).Log(...)
.go-kit/log
provides structured logs and I tried to use existing keys that were already used.