From 44cee32e39091a2a900302e6b93db6dc9bfaede3 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Fri, 3 Nov 2023 10:35:00 -0700 Subject: [PATCH] zapslog: Apply callerSkip when addCaller --- exp/zapslog/handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exp/zapslog/handler.go b/exp/zapslog/handler.go index 982d9bccd..a006879c1 100644 --- a/exp/zapslog/handler.go +++ b/exp/zapslog/handler.go @@ -137,6 +137,11 @@ func (h *Handler) Handle(ctx context.Context, record slog.Record) error { } if h.addCaller && record.PC != 0 { + if h.callerSkip != 0 { + var pcs [1]uintptr + runtime.Callers(4+h.callerSkip, pcs[:]) + record.PC = pcs[0] + } frame, _ := runtime.CallersFrames([]uintptr{record.PC}).Next() if frame.PC != 0 { ce.Caller = zapcore.EntryCaller{