mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Update handler_glog.go
This commit is contained in:
parent
c28a4caa7f
commit
011c8d15c5
1 changed files with 10 additions and 3 deletions
|
|
@ -139,11 +139,15 @@ func (h *GlogHandler) Vmodule(ruleset string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enabled implements slog.Handler, reporting whether the handler handles records
|
||||||
|
// at the given level.
|
||||||
func (h *GlogHandler) Enabled(ctx context.Context, lvl slog.Level) bool {
|
func (h *GlogHandler) Enabled(ctx context.Context, lvl slog.Level) bool {
|
||||||
// fast-track skipping logging if override not enabled and the provided verbosity is above configured
|
// fast-track skipping logging if override not enabled and the provided verbosity is above configured
|
||||||
return h.override.Load() || slog.Level(h.level.Load()) <= lvl
|
return h.override.Load() || slog.Level(h.level.Load()) <= lvl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithAttrs implements slog.Handler, returning a new Handler whose attributes
|
||||||
|
// consist of both the receiver's attributes and the arguments.
|
||||||
func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||||
h.lock.RLock()
|
h.lock.RLock()
|
||||||
siteCache := maps.Clone(h.siteCache)
|
siteCache := maps.Clone(h.siteCache)
|
||||||
|
|
@ -164,13 +168,16 @@ func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||||
return &res
|
return &res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithGroup implements slog.Handler, returning a new Handler with the given
|
||||||
|
// group appended to the receiver's existing groups.
|
||||||
|
//
|
||||||
|
// Note, this function is not implemented.
|
||||||
func (h *GlogHandler) WithGroup(name string) slog.Handler {
|
func (h *GlogHandler) WithGroup(name string) slog.Handler {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle implements slog.Handler.Handle
|
// Handle implements slog.Handler, filtering a log record through the global,
|
||||||
// If the global log level allows, fast track logging.
|
// local and backtrace filters, finally emitting it if either allow it through.
|
||||||
// Else use the calculated log level to track logging or drop it.
|
|
||||||
func (h *GlogHandler) Handle(_ context.Context, r slog.Record) error {
|
func (h *GlogHandler) Handle(_ context.Context, r slog.Record) error {
|
||||||
// If the global log level allows, fast track logging
|
// If the global log level allows, fast track logging
|
||||||
if slog.Level(h.level.Load()) <= r.Level {
|
if slog.Level(h.level.Load()) <= r.Level {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue