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

Give the library user a method to customize the reportcaller output #887

Closed
GAZ082 opened this issue Jan 13, 2019 · 13 comments
Closed

Give the library user a method to customize the reportcaller output #887

GAZ082 opened this issue Jan 13, 2019 · 13 comments

Comments

@GAZ082
Copy link

GAZ082 commented Jan 13, 2019

Hey. When I enable it i get an absolute path to the code line:

"file":"/home/gabriel/go/src/someprogram/package/subpackage/subpackage.go:303

I just need the last few charactes, ie: subpackage.go:303

You guys know some way to get this that way?

Thanks!

@richpoirier
Copy link
Collaborator

@GAZ082 unfortunately no, there's no way to do that currently.

@quancore
Copy link

This definitely needs to implement otherwise, outputs seem very ugly. I am wondering what is hindering you to just truncate last part of caller method path?

@GAZ082
Copy link
Author

GAZ082 commented Jan 16, 2019

Ignorance? Haha. Have no idea how to work around this.

@dgsb
Copy link
Collaborator

dgsb commented Jan 16, 2019

There is no actual way to do that from a library user standpoint. The formatting is of file data fields is done at the fomatter level which is not customizable.
We need to think how we would like to provide a library user to customize the output of such information.
The usual way is to use a hooks, but it is not feasible with this implementation.

@dgsb dgsb changed the title How to shorten the reportcaller output? Give the library user a method to customize the reportcaller output Jan 16, 2019
@dgsb
Copy link
Collaborator

dgsb commented Jan 16, 2019

by the way @GAZ082 thanks for your feedback on this feature.

@dgsb dgsb pinned this issue Jan 16, 2019
@GAZ082
Copy link
Author

GAZ082 commented Jan 17, 2019

@dgsb no problem David, than you for being so nice. Looking forward this feature!

@tossp
Copy link

tossp commented Jan 27, 2019

I submitted a solution(#898 ) that I am using, which is expected to meet your needs, but I did not do performance testing.

@GAZ082
Copy link
Author

GAZ082 commented Jan 29, 2019

Hey, looks handy! Is there any way I can load this up in my local version of logrus? I'm sure some git command to suck your commit up and merge it in my local version?

@dgsb
Copy link
Collaborator

dgsb commented Feb 27, 2019

@GAZ082 I've added a callback to the json formatter in order to give the user a chance to format the runtime.Frame himself. Would that help you ?

@dgsb
Copy link
Collaborator

dgsb commented Feb 27, 2019

it's here #909

@dgsb
Copy link
Collaborator

dgsb commented Feb 27, 2019

The same customization has been added to the text formatter #911

@GAZ082
Copy link
Author

GAZ082 commented Feb 28, 2019

Thank you @dgsb ! Been looking into the commit and could not figure it out how to implement it. Any example would be welcomed!

@dgsb
Copy link
Collaborator

dgsb commented Mar 3, 2019

@GAZ082 I've added an example in #913
I'm going to merge that soon

@dgsb dgsb closed this as completed Mar 6, 2019
@dgsb dgsb unpinned this issue Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants