-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow passing custom logger #10
Comments
Hi @sajal sorry for the late reply, I did some changes but after doing some tests I think is better to add the logger in a middleware. In any case, I will try to see what could I do, mainly because the logger may need a custom responseWriter that depending on the logger it should be adapted. Any ideas are more than welcome. |
@sajal What do you think about this: https://github.com/nbari/violetear/blob/master/violetear.go#L69 Basically, ask for a function so that you can pass the response writer:
The default one to use is this one: https://github.com/nbari/violetear/blob/master/logger.go Please give a try and let me know what you think. |
Thats useful. Looks like my code can use different logging paths based on status, etc... |
I still doing some improvements, for the idea is that based on your logger you can manipulate the as required, the function needs to be:
And from there you can take or use any of the ResponseWriter, or the Request. I will document this later, any ideas are more than welcome. |
Currently setting
router.LogRequests = true
, the requests logs are printed to stderr using default format. But I would like some way to pass a custom logger, example: logrus . Most logging implementations can be abstracted to a simple interface.If provided use it, otherwise use the default behavior.
The text was updated successfully, but these errors were encountered: