slog: fix nopc code
Update the functions in nopc.go to match the recent changes
in how the pc is fetched.
Change-Id: I1d96ba3cbad88cc9daf53496dfbac5d2fd4a3548
Reviewed-on: https://go-review.googlesource.com/c/exp/+/461995
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/slog/nopc.go b/slog/nopc.go
index a4c5228..0461cab 100644
--- a/slog/nopc.go
+++ b/slog/nopc.go
@@ -16,7 +16,7 @@
if !l.Enabled(level) {
return
}
- l.logDepth(nil, 0, level, msg, args...)
+ l.logPC(nil, 0, level, msg, args...)
}
// LogAttrsDepth is like [Logger.LogAttrs], but accepts a call depth argument
@@ -37,7 +37,10 @@
// the Record's pc, and remove this function. See the comment on
// TestConnections/wrap_default_handler.
func (l *Logger) logDepthErr(err error, calldepth int, level Level, msg string, args ...any) {
- l.logDepth(err, 0, level, msg, args...)
+ if !l.Enabled(level) {
+ return
+ }
+ l.logPC(err, 0, level, msg, args...)
}
// pc returns 0 to avoid incurring the cost of runtime.Callers.