I was looking at replacing logrus with the new slog library in our project. 
 I noticed that it uses runtime.Callers() with a fixed skip 
<https://cs.opensource.google/go/x/exp/+/d63ba01a:slog/logger.go;l=240> to 
collect the PC of the calling code, presumably to make it possible for the 
handler to emit line number and filename.

Question is: is that sound in the face of inlining functions?  I think if 
the Info method gets inlined then the skip might be too large, for example.

I remember having to change similar code in our project to use 
runtime.CallersFrames in order to deal with inlining. Quite possible 
there's a way to deal with an inlined PC that I wasn't aware of, but it 
seemed wrong to me.

-Shaun

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/62c4950a-bf24-40f6-a17b-b3ef20099be4n%40googlegroups.com.

Reply via email to