-
Notifications
You must be signed in to change notification settings - Fork 32
fix: Apply log level filtering to BufferHandler to suppress debug messages #103
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
Changes from all commits
ea6e027
fed4e31
238107a
323fc25
db5609f
36fedbf
c677f72
32b76b9
462b804
709002b
adb5b51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,17 @@ | |
| LEVEL_MAP = { | ||
| "DEBUG": logging.DEBUG, | ||
| "INFO": logging.INFO, | ||
| "WARN": logging.WARNING, | ||
| "WARNING": logging.WARNING, | ||
| "ERROR": logging.ERROR, | ||
| "CRITICAL": logging.CRITICAL, | ||
| } | ||
|
|
||
| # Normalize non-standard level names to Python conventions | ||
| LEVEL_NORMALIZE = { | ||
| "WARN": "WARNING", | ||
| } | ||
|
Comment on lines
9
to
+21
|
||
|
|
||
|
|
||
| class LogParser: | ||
| def __init__(self, collector_logger: logging.Logger): | ||
|
|
@@ -37,7 +43,9 @@ def parse_and_log(self, line: str): | |
| # Preserve incoming JSON fields, but ensure timestamp is present | ||
| parsed.setdefault("timestamp", str(timestamp)) | ||
| level_name = parsed.get("level", "INFO") | ||
| level_name = LEVEL_NORMALIZE.get(level_name, level_name) | ||
| level = LEVEL_MAP.get(level_name, logging.INFO) | ||
| parsed["level"] = level_name | ||
|
Comment on lines
45
to
+48
|
||
| log_entry = parsed | ||
| else: | ||
| raise ValueError("Not a valid log JSON dict") | ||
|
|
@@ -46,6 +54,7 @@ def parse_and_log(self, line: str): | |
| match = LOG_PATTERN.match(sline) | ||
| if match: | ||
| level_name = match["level"] | ||
| level_name = LEVEL_NORMALIZE.get(level_name, level_name) | ||
| level = LEVEL_MAP.get(level_name, logging.INFO) | ||
| message = match["message"] | ||
| else: | ||
|
|
||
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.
This test mutates global configuration (
LoggerConfig.print_debug) and relies on cleanup infinally. To improve isolation (especially if the suite ever runs tests concurrently), prefer using pytest’smonkeypatchfixture (or an equivalent config fixture) to scope the config change to this test and automatically restore the original value.