-
Notifications
You must be signed in to change notification settings - Fork 742
[BugFix] Fix legacy logger propagation leaking unformatted logs to stderr #7617
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: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -246,8 +246,7 @@ def get_trace_logger(self, name, file_name, without_formater=False, print_to_con | |||
| logger.addHandler(console_handler) | ||||
| console_handler.propagate = False | ||||
|
|
||||
| # Set propagate (maintain original logic) | ||||
| # logger.propagate = False | ||||
| logger.propagate = False | ||||
|
|
||||
| return logger | ||||
|
|
||||
|
|
@@ -311,8 +310,7 @@ def _get_legacy_logger(self, name, file_name, without_formater=False, print_to_c | |||
| logger.addHandler(console_handler) | ||||
| console_handler.propagate = False | ||||
|
||||
| console_handler.propagate = False |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ def test_legacy_logger_creation(self): | |
| def test_logger_propagate(self): | ||
| """Test log propagation settings""" | ||
| legacy_logger = self.logger._get_legacy_logger("test", "test.log") | ||
| self.assertTrue(legacy_logger.propagate) | ||
| self.assertFalse(legacy_logger.propagate) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 建议 本次 PR 同时修复了 建议补充: def test_logger_propagate(self):
"""Test log propagation settings"""
legacy_logger = self.logger._get_legacy_logger("test", "test.log")
self.assertFalse(legacy_logger.propagate)
# Also verify get_trace_logger
trace_logger = self.logger.get_trace_logger("test_trace", "test_trace.log")
self.assertFalse(trace_logger.propagate) |
||
|
|
||
| def test_get_trace_logger_basic(self): | ||
| """Test basic functionality of get_trace_logger""" | ||
|
|
||
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.
这里对
console_handler设置propagate没有实际效果:propagate是logging.Logger的属性,不是logging.Handler的属性。该行会让人误以为 handler 能控制传播,建议删除该行,统一由logger.propagate = False控制。