Skip to content

Commit

Permalink
Merge pull request #51 from linuxboot/fix/logrus_fix_caller_hook
Browse files Browse the repository at this point in the history
fix(xcontext): Fix caller file detection in logrus
  • Loading branch information
xaionaro authored Dec 9, 2021
2 parents 027c811 + d35fc54 commit 750bbda
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/xcontext/logger/logadapter/logrus/fix_caller_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (fixCallerHook) Fire(entry *logrus.Entry) error {
return nil
}

if !strings.HasPrefix(entry.Caller.Function, "github.com/linuxboot/contest/pkg/xcontext") {
if !strings.Contains(entry.Caller.Function, "github.com/linuxboot/contest/pkg/xcontext") {
// if the value is already correct, then there's nothing to do.
return nil
}
Expand All @@ -51,7 +51,7 @@ func (fixCallerHook) Fire(entry *logrus.Entry) error {
frames := runtime.CallersFrames(programCounters[0:n])
for {
frame, more := frames.Next()
if !strings.HasPrefix(frame.Function, "github.com/linuxboot/contest/pkg/xcontext") &&
if !strings.Contains(frame.Function, "github.com/linuxboot/contest/pkg/xcontext") &&
!strings.Contains(strings.ToLower(frame.Function), "github.com/sirupsen/logrus") {
entry.Caller = &frame
return nil
Expand Down

0 comments on commit 750bbda

Please sign in to comment.