mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-19 14:29:27 +00:00
log: allow --vmodule to downgrade the log level
This commit is contained in:
parent
68d523ccdd
commit
0f03ee83e8
1 changed files with 5 additions and 3 deletions
|
|
@ -52,7 +52,8 @@ type GlogHandler struct {
|
||||||
// to Google's glog logger. The returned handler implements Handler.
|
// to Google's glog logger. The returned handler implements Handler.
|
||||||
func NewGlogHandler(h slog.Handler) *GlogHandler {
|
func NewGlogHandler(h slog.Handler) *GlogHandler {
|
||||||
return &GlogHandler{
|
return &GlogHandler{
|
||||||
origin: h,
|
origin: h,
|
||||||
|
siteCache: make(map[uintptr]slog.Level),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,9 +197,10 @@ func (h *GlogHandler) Handle(_ context.Context, r slog.Record) error {
|
||||||
h.siteCache[r.PC], lvl, ok = rule.level, rule.level, true
|
h.siteCache[r.PC], lvl, ok = rule.level, rule.level, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If no rule matched, remember to drop log the next time
|
// If no rule matched, use the default log lvl
|
||||||
if !ok {
|
if !ok {
|
||||||
h.siteCache[r.PC] = 0
|
lvl = slog.Level(h.level.Load())
|
||||||
|
h.siteCache[r.PC] = lvl
|
||||||
}
|
}
|
||||||
h.lock.Unlock()
|
h.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue