TV4 / logrus-stackdriver-formatter

Stackdriver formatter for logrus
MIT License
43 stars 32 forks source link

Fix stack depth 2nd try #3

Closed tglander closed 6 years ago

tglander commented 6 years ago

Hey again, I prepared another PR, this time I also adapted the test (sorry for the last PR). To explain a bit more: you are using a fixed number of skip frames to identify the function calling log.Error or log.Errorf, for example. The problem is, that this number is not constant. For example Errorf will first format and then call Error. My solution goes up the stack frame by frame, and checks wether the package of the current frame's function is logrus. It stops at the first package that is not logrus.

You can even see that the current test is testing the wrong stuff, as all expected line numbers are 28. This is clearly not the case, as Error is called on multiple different lines.

marcusolsson commented 6 years ago

Closed in favor of #4