-
Notifications
You must be signed in to change notification settings - Fork 36
fix: restore log flow to root logger on disable (DM-3439) #2429
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
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
58b143f to
e20a964
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2429 +/- ##
==========================================
+ Coverage 91.28% 91.33% +0.04%
==========================================
Files 192 192
Lines 26184 26176 -8
==========================================
+ Hits 23903 23907 +4
+ Misses 2281 2269 -12
🚀 New features to boost your workflow:
|
|
/gemini review |
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.
Code Review
This pull request effectively addresses a critical bug where disabling debug logging would silence the logger entirely. The changes are well-implemented, replacing the unsafe direct manipulation of logger.handlers with the thread-safe addHandler and removeHandler methods, and correctly restoring log propagation. The refactoring of DebugLogFormatter is also a great improvement in simplicity and correctness. I've added a couple of suggestions to further enhance thread safety by iterating over a copy of the handlers list, which fully resolves the race condition concerns mentioned in the description.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Description
https://cognitedata.atlassian.net/browse/DM-3439
In the SDK, we accept the “debug: bool = False” parameter, which also can be turned on or off later. It has 2 main issues:
1. Critical Issue: The "Silent Logger" Bug
_disable_debug_logging()leaves the logger in a broken state.The Flow:
_configure_logger_for_debug_mode()sets logger.propagate = False._disable_debug_logging()clears all handlers (logger.handlers = []) but does not reset propagate toTrue.The Result: After you enable and then disable debug mode, the logger has no handlers and does not propagate to the root logger. Any subsequent logs (even errors or warnings) will be silently swallowed and effectively lost.
Fix: Restore propagation in the disable function.
2. High Risk: Direct List Manipulation
Directly assigning
logger.handlers = []is generally discouraged in Python logging for two reasons: