evalphobia / logrus_sentry

sentry hook for logrus
MIT License
194 stars 78 forks source link

Logging wrapper gets caught as culprit #59

Open mightyguava opened 6 years ago

mightyguava commented 6 years ago

I'm using a wrapper for the logrus library to add file/line and just as an internal abstraction for the logging library.

After starting to use the wrapper, I'm seeing that when an error is logged by library code, the culprit is identified as a frame in the log wrapper, because I have the InAppPrefix set to the top-level package path for my project.

I think an example serves best here:

github.com/myproject/
  myapp/
     main.go
  mylib/
    foo.go <= This logs an exception
  logwrapper/
    wrapper.go

I can't just set Skip to the right number on the StackTraceConfiguration, because Errorf and Error differ by 1 stack frame, since Errorf calls Error

Do you have any thoughts on how to get the culprit become the line that logs in foo.go? The options that I see are: