Skip to content

Commit 54f8e02

Browse files
log: fix some functions comments (ethereum#29907)
updates some docstrings --------- Co-authored-by: rjl493456442 <[email protected]>
1 parent 9e03447 commit 54f8e02

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

log/handler_glog.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,15 @@ func (h *GlogHandler) Vmodule(ruleset string) error {
139139
return nil
140140
}
141141

142+
// Enabled implements slog.Handler, reporting whether the handler handles records
143+
// at the given level.
142144
func (h *GlogHandler) Enabled(ctx context.Context, lvl slog.Level) bool {
143145
// fast-track skipping logging if override not enabled and the provided verbosity is above configured
144146
return h.override.Load() || slog.Level(h.level.Load()) <= lvl
145147
}
146148

149+
// WithAttrs implements slog.Handler, returning a new Handler whose attributes
150+
// consist of both the receiver's attributes and the arguments.
147151
func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
148152
h.lock.RLock()
149153
siteCache := maps.Clone(h.siteCache)
@@ -164,12 +168,16 @@ func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
164168
return &res
165169
}
166170

171+
// WithGroup implements slog.Handler, returning a new Handler with the given
172+
// group appended to the receiver's existing groups.
173+
//
174+
// Note, this function is not implemented.
167175
func (h *GlogHandler) WithGroup(name string) slog.Handler {
168176
panic("not implemented")
169177
}
170178

171-
// Log implements Handler.Log, filtering a log record through the global, local
172-
// and backtrace filters, finally emitting it if either allow it through.
179+
// Handle implements slog.Handler, filtering a log record through the global,
180+
// local and backtrace filters, finally emitting it if either allow it through.
173181
func (h *GlogHandler) Handle(_ context.Context, r slog.Record) error {
174182
// If the global log level allows, fast track logging
175183
if slog.Level(h.level.Load()) <= r.Level {

log/logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535
LvlDebug = LevelDebug
3636
)
3737

38-
// convert from old Geth verbosity level constants
38+
// FromLegacyLevel converts from old Geth verbosity level constants
3939
// to levels defined by slog
4040
func FromLegacyLevel(lvl int) slog.Level {
4141
switch lvl {
@@ -107,7 +107,7 @@ type Logger interface {
107107
// With returns a new Logger that has this logger's attributes plus the given attributes
108108
With(ctx ...interface{}) Logger
109109

110-
// With returns a new Logger that has this logger's attributes plus the given attributes. Identical to 'With'.
110+
// New returns a new Logger that has this logger's attributes plus the given attributes. Identical to 'With'.
111111
New(ctx ...interface{}) Logger
112112

113113
// Log logs a message at the specified level with context key/value pairs

0 commit comments

Comments
 (0)