MCPcopy Create free account
hub / github.com/prometheus/common / SetLevel

Method SetLevel

promlog/log.go:178–192  ·  view source on GitHub ↗

SetLevel changes the log level.

(lvl *AllowedLevel)

Source from the content-addressed store, hash-verified

176
177// SetLevel changes the log level.
178func (l *logger) SetLevel(lvl *AllowedLevel) {
179 l.mtx.Lock()
180 defer l.mtx.Unlock()
181 if lvl == nil {
182 l.leveled = log.With(l.base, "ts", timestampFormat, "caller", log.DefaultCaller)
183 l.currentLevel = nil
184 return
185 }
186
187 if l.currentLevel != nil && l.currentLevel.s != lvl.s {
188 _ = l.base.Log("msg", "Log level changed", "prev", l.currentLevel, "current", lvl)
189 }
190 l.currentLevel = lvl
191 l.leveled = level.NewFilter(log.With(l.base, "ts", timestampFormat, "caller", log.Caller(5)), lvl.o)
192}

Callers 2

NewDynamicWithLoggerFunction · 0.95
TestDynamicFunction · 0.80

Calls 1

LogMethod · 0.45

Tested by 1

TestDynamicFunction · 0.64