From eb9347f6e7848c4336dae871c0f01bef55fd7b63 Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 26 Sep 2021 20:57:09 +0800 Subject: [PATCH] promlog: check the log level first (#322) Signed-off-by: royeo --- promlog/log.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/promlog/log.go b/promlog/log.go index adb0599c..b7c7608f 100644 --- a/promlog/log.go +++ b/promlog/log.go @@ -118,10 +118,11 @@ func New(config *Config) log.Logger { l = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr)) } + l = log.With(l, "ts", timestampFormat, "caller", log.DefaultCaller) + if config.Level != nil { l = level.NewFilter(l, config.Level.o) } - l = log.With(l, "ts", timestampFormat, "caller", log.DefaultCaller) return l }