-
Notifications
You must be signed in to change notification settings - Fork 387
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
fix(log): add logger for kazoo.handlers.threading #725
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #725 +/- ##
==========================================
- Coverage 96.73% 96.65% -0.09%
==========================================
Files 27 27
Lines 3556 3560 +4
==========================================
+ Hits 3440 3441 +1
- Misses 116 119 +3 ☔ View full report in Codecov by Sentry. |
Hi @zqfan. Thank you for the PR but, I am sorry but I am not clear on the goals of this PR. |
kazoo/kazoo/handlers/threading.py Line 121 in b00d88f
But it might be better if wen can specify a logger handler, which allows us to print log info into a specific file. Upper level application can only deal with kazoo.client, and it is not a good idea to expose kazoo/handlers/threading.py detail to upper level just for a logger handler, so I let it inherit the logger setting in kazoo.client. this pr keeps same behavior as before, if user don't specify a dedicated logger handler |
Thank you for the PR. Just like @ceache said, I am also not sure about the goal of this PR. I understand the issue about the However, I don't think passing a logger should be the way to go. |
My project doesn't configure a logging.basicConfig for everything, it adjust and control major module's behaviour separately. For now, to avoid too much message printed to my log file, I have to do something like this: logger = logging.getLogger("kazoo.client")
logger.setLevel(logging.ERROR) // for other module, it is INFO
for h in mymodule.logger.handlers: // a different file for other module
logger.addHandler(h)
self.client = KazooClient(hosts=ZK_HOSTS,logger=logger) If kazoo.handlers.threading could not inherit logger settings from kazoo client, then I have to do it twice. |
That can already be done: import logging
logging.basicConfig(level=logging.INFO)
...
logger = logging.getLogger("kazoo")
logger.setLevel(logging.ERROR) @ceache I think the possible use case for this, which is not explained here or in the initial issue, is the same as the reason why we have a |
I understand what you're trying to achieve, but as @StephenSorriaux points out above, I think it's already solvable if you change the logger you're tuning to May I recommend @brandon-rhodes excellent Closing, but if for some reason you can't achieve this with existing tooling please comment and we can re-evaluate. |
Fixes #724
No handlers could be found for logger "kazoo.handlers.threading"
for better logging control, just like kazoo.client does