-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
re-implementing default logging middleware #313
re-implementing default logging middleware #313
Conversation
2ae7226
to
e4c5bb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good PR!
Looking very close to what I expected, thank you very much.
I'd let the possibility for users to provide their own requestId, that's a really common use case. Just add a func() string
in LoggingConfig :)
Thank you again!
Also, I'd add some tests with |
abd8127
to
82efea5
Compare
The only thing I haven't addressed yet is failing tests due to including the new mw in open api docs: expected: "#### Controller: \n\n`github.com/go-fuego/fuego_test.helloWorld`\n\n---\n\ntest description"
actual : "#### Controller: \n\n`github.com/go-fuego/fuego_test.helloWorld`\n\n#### Middlewares:\n\n- `github.com/go-fuego/fuego.NewServer.defaultLoggingMiddleware.func16`\n\n---\n\ntest description" ./examples/petstore/lib/server_test.go: (I guess this would be best fixed with simple golden file update) openapi_operations_test.go/options_test.go I'm not sure what the best way to approach this is for these tests. I guess 2 options off the top of my head are
Any other ideas? |
82efea5
to
2a657fb
Compare
Please update the tests with We don't want to hide anything |
Yes and we need a goodNaming. I suggest Also, I think that if you keep the closure pattern, you'll always have a |
@EwenQuim thanks for the feedback. defaultLogger makes sense for now. I guess it can be changed in future if needed. Changes have been made, all tests are now passing :) |
On mobile, can you send a picture of the way it looks in stoplight? |
@dylanhitt Not sure what you mean? Do you mean how the open api spec renders when it has this middleware? (using stoplight on mobile?) If I am completely misunderstanding and you mean you're on mobile and would like a screenshot, here you go, its the pet open api doc: |
Oh no, the screenshot is what I needed. Thank you. I like this |
cd306cc
to
7fa2a70
Compare
This PR implements a simplified default logging middleware, taking on feedback from #303.
These changes simplify #303 and just provides default req/res logging, with options to disable either. Rather than supporting custom logging functions, users who need custom logging can just implement their own mw.
I see some of these use cases:
After thinking about how to do this, supporting case 4 does seems unnecessary and more complex that it needs to be - for users needing custom logging it would be cleaner to just implement their own.
Note: Some tests are failing for now due to some golden files not expecting this new middleware by default.