mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
remove FuncHandler
This commit is contained in:
parent
32a47ad53b
commit
a4f99966ab
1 changed files with 0 additions and 32 deletions
|
|
@ -72,38 +72,6 @@ func (h *discardHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
|||
return &discardHandler{}
|
||||
}
|
||||
|
||||
type funcHandler struct {
|
||||
handler handlerFunc
|
||||
attrs []slog.Attr
|
||||
}
|
||||
|
||||
type handlerFunc func(_ context.Context, r slog.Record) error
|
||||
|
||||
// FuncHandler returns a handler which forwards all records to the provided handler function
|
||||
func FuncHandler(fn handlerFunc) slog.Handler {
|
||||
return &funcHandler{fn, []slog.Attr{}}
|
||||
}
|
||||
|
||||
func (h funcHandler) Handle(_ context.Context, r slog.Record) error {
|
||||
r.AddAttrs(h.attrs...)
|
||||
return h.handler(context.Background(), r)
|
||||
}
|
||||
|
||||
func (h *funcHandler) Enabled(_ context.Context, level slog.Level) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *funcHandler) WithGroup(name string) slog.Handler {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (h *funcHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||
return &funcHandler{
|
||||
h.handler,
|
||||
append(h.attrs, attrs...),
|
||||
}
|
||||
}
|
||||
|
||||
type terminalHandler struct {
|
||||
mu sync.Mutex
|
||||
wr io.Writer
|
||||
|
|
|
|||
Loading…
Reference in a new issue