Skip to content

Commit a6782a7

Browse files
committed
cmd,log: using DiscardHandler in go std lib
1 parent d39af34 commit a6782a7

File tree

4 files changed

+5
-26
lines changed

4 files changed

+5
-26
lines changed

cmd/devp2p/runtest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package main
1818

1919
import (
20+
"log/slog"
2021
"os"
2122

2223
"github.com/ethereum/go-ethereum/cmd/devp2p/internal/v4test"
@@ -86,7 +87,7 @@ func runTests(ctx *cli.Context, tests []utesting.Test) error {
8687
}
8788
// Disable logging unless explicitly enabled.
8889
if !ctx.IsSet("verbosity") && !ctx.IsSet("vmodule") {
89-
log.SetDefault(log.NewLogger(log.DiscardHandler()))
90+
log.SetDefault(log.NewLogger(slog.DiscardHandler))
9091
}
9192
// Run the tests.
9293
var run = utesting.RunTests

cmd/workload/testsuite.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"embed"
2121
"errors"
2222
"io/fs"
23+
"log/slog"
2324
"os"
2425

2526
"github.com/ethereum/go-ethereum/core/history"
@@ -240,7 +241,7 @@ func runTestCmd(ctx *cli.Context) error {
240241

241242
// Disable logging unless explicitly enabled.
242243
if !ctx.IsSet("verbosity") && !ctx.IsSet("vmodule") {
243-
log.SetDefault(log.NewLogger(log.DiscardHandler()))
244+
log.SetDefault(log.NewLogger(slog.DiscardHandler))
244245
}
245246

246247
// Run the tests.

log/handler.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,6 @@ import (
1313
"github.com/holiman/uint256"
1414
)
1515

16-
type discardHandler struct{}
17-
18-
// DiscardHandler returns a no-op handler
19-
func DiscardHandler() slog.Handler {
20-
return &discardHandler{}
21-
}
22-
23-
func (h *discardHandler) Handle(_ context.Context, r slog.Record) error {
24-
return nil
25-
}
26-
27-
func (h *discardHandler) Enabled(_ context.Context, level slog.Level) bool {
28-
return false
29-
}
30-
31-
func (h *discardHandler) WithGroup(name string) slog.Handler {
32-
panic("not implemented")
33-
}
34-
35-
func (h *discardHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
36-
return &discardHandler{}
37-
}
38-
3916
type TerminalHandler struct {
4017
mu sync.Mutex
4118
wr io.Writer

log/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var (
1212
)
1313

1414
func init() {
15-
root = &logger{slog.New(DiscardHandler())}
15+
root = &logger{slog.New(slog.DiscardHandler)}
1616
}
1717

1818
// SetDefault sets the default global logger

0 commit comments

Comments
 (0)