aboutsummaryrefslogtreecommitdiff
path: root/src/log/slog/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/log/slog/handler.go')
-rw-r--r--src/log/slog/handler.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/log/slog/handler.go b/src/log/slog/handler.go
index 66eea02aa5..e56be5f494 100644
--- a/src/log/slog/handler.go
+++ b/src/log/slog/handler.go
@@ -299,7 +299,11 @@ func (h *commonHandler) handle(r Record) error {
}
// source
if h.opts.AddSource {
- state.appendAttr(Any(SourceKey, r.source()))
+ src := r.Source()
+ if src == nil {
+ src = &Source{}
+ }
+ state.appendAttr(Any(SourceKey, src))
}
key = MessageKey
msg := r.Message