-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: add optional logger wherever possible #3560
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
base: master
Are you sure you want to change the base?
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
|
@ccoVeille thank you for opening this PR. I am willing to work with you on improving the logging and do agree that the current interface lacks some useful features. If you have a current need to just be able to set logger per client, we can improve this initially and then continue on the whole logging interface. |
|
I found a workaround by injecting a dedicated logger in the context and restoring from the context in the current Printf interface. So I don't have a need right now. We can work together on the target solution you planned initially for the v10 with a fallback for the v9 |
|
so @ccoVeille would you consider this pr ready for review ? |
|
Yes, you can review. I'm curious about your feedback. I dislike the idea it adds a configuration option in each struct that satisfies the current internal.Logging interface. I feel like we shouldn't add option with interface we may change for supporting the log level and other things you listed. So here I'm open to suggestions. |
Ping @ndyakov Maybe I should have pinged you |
|
@ccoVeille just moved it to Ready for Review and will work on reviewing it this week, thank you. |
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.
@ccoVeille thank you! Left some comments. What came to mind is that we can try to compose an Logger in those structs, but let's keep this for the future. For now, let's address the pointer to an interface and the ordering of the loggers when we decide which one to use. I am fine with any of the two approaches mentioned (e.g. by using the custom as default and fallback to the internal OR by having an explicit IF/ELSE statement)
This commit introduces an optional logger parameter to various structs. This enhancement allows users to provide custom logging implementations.
5c464f7 to
87239bb
Compare
|
@ndyakov I applied your suggestions to the first commit Then I have added another commit where I apply something that seems to me to be better. Let me know what you think. |
|
I found a panic in the code, I made a fix for this branch, but you may want me to fix it separately The bug is here, because err can be nil go-redis/maintnotifications/handoff_worker.go Lines 484 to 490 in c176672
But here the call to reason.Error() will panic go-redis/internal/maintnotifications/logs/log_messages.go Lines 298 to 303 in c176672
Here is the code that spotted it because of my refactoring to always call the logger, and so remove the test on WarnOrAbove |
This commit introduces an optional logger parameter to various structs.
This enhancement allows users to provide custom logging implementations.
This is a naive implementation of #3558
It is provided to iterate on the changes, there are many things that are missing:
Also, the current discussion in #3558 let me think the current logging interface should be reconsidered, so everything will have to be refactored.