Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use report correctly to get the correct method name when I wrap logrus? #1360

Closed
agclqq opened this issue Nov 25, 2022 · 2 comments
Closed
Labels

Comments

@agclqq
Copy link

agclqq commented Nov 25, 2022

When I wrap logrus, I can't get the right call method.

Like the following code
a.go

...
  func Test(){
      b.Info(ctx,logMsg)
  }
...

b.go

...
    type BusinessLog struct {
	*logrus.Logger
    }
   var std = NewBusinessLog()
   func NewBusinessLog() *BusinessLog {
	ln := logrus.New()
	ln.SetReportCaller(true)
        ...
        return &BusinessLog{Logger: ln}
    }
    
    func Info(ctx context.Context, v interface{}){
         traceId:=trace.GetId(ctx)
         std.Logger.WithField("traceId", traceId).Info(v)  
    }
...

expectation
Method name Test in the file a.go

practical
Method name Info int the file b.go

question
How do I get the method name Test in file a.go?

Thank you

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Dec 26, 2022
@github-actions
Copy link

github-actions bot commented Jan 9, 2023

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant