Repository navigation
feat(logging): per-module log filters and default to DEBUG log levels - #2477
Open
presentyourlove wants to merge 1 commit into
Open
presentyourlove wants to merge 1 commit into
presentyourlove wants to merge 1 commit into
Conversation
- Add parse_module_log_filters to parse comma-separated module=LEVEL specifications - Implement create_module_log_filter with hierarchical prefix matching for Loguru records - Update file logging in logger_setup to default to DEBUG level for comprehensive diagnostic persistence - Add --log-modules CLI argument in Args and respect EXO_LOG_MODULES environment variable - Suppress noisy third-party loggers (httpx, httpcore, urllib3, asyncio, anyio, zenoh, hpack) to WARNING - Add comprehensive automated unit tests in test_module_logging.py covering parsing, prefix matching, console output, file defaults, and CLI/ENV options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements official TODO item #27: "Log cleanup - per-module log filters and default to DEBUG log levels".
Background & Problem
Prior to this PR:
-q, default,-v). Setting-v(DEBUG) caused all modules—including high-frequency polling monitors (info_gatherer, macmon), network ping heartbeats, and low-level communication libraries—to spam the console and log files simultaneously.exo.routingorexo.download) could not selectively enable debug messages for that module without getting overwhelmed by unrelated logs.EXO_LOG) only loggedINFOby default unless-vwas passed. In production or background service runs, crashes or unexpected node drops lacked crucial pre-crash debug context.httpx,httpcore,urllib3,asyncio,anyio,zenoh,hpack) lacked centralized suppression.Solution
This PR introduces per-module log filtering with hierarchical prefix matching, defaults file logging to DEBUG, and cleans up log spam:
Module Log Filter Parsing (
src/exo/shared/logging.py):parse_module_log_filters(filter_str: str | None) -> dict[str, str]: Parses comma-separated module specifications (e.g.exo.routing=DEBUG,exo.master=INFO,exo.download=WARNING).Hierarchical Log Filtering (
src/exo/shared/logging.py):create_module_log_filter(module_levels, base_level): Matches records against module prefixes.exo.routing=DEBUGandexo.routing.zenoh=WARNINGenables DEBUG forexo.routing.routerwhile suppressing verbose packets fromexo.routing.zenoh.record["name"]) and dynamically bound module contexts (record["extra"]["name"]).Default to DEBUG for File Logs:
logger_setupnow defaultsfile_log_levelto"DEBUG".Third-Party Log Cleanup:
httpx,httpcore,urllib3,asyncio,anyio,zenoh,hpack) toWARNING.CLI & Environment Variable Configuration (
src/exo/main.py):--log-modulesoption toexoCLI.EXO_LOG_MODULESenvironment variable (e.g.export EXO_LOG_MODULES="exo.routing=DEBUG,exo.download=DEBUG").logger_setup.Automated Unit Tests (
src/exo/shared/tests/test_module_logging.py):--log-modulesargument andEXO_LOG_MODULESenvironment variable integration.Verification
.venv/Scripts/pytest.exe src/exo/shared/tests/test_console_verbosity.py src/exo/shared/tests/test_log_rotation.py src/exo/shared/tests/test_module_logging.py -v # 15 passed in 3.52s.venv/Scripts/ruff.exe check src/exo/shared/logging.py src/exo/shared/tests/test_module_logging.py .venv/Scripts/ruff.exe format --check ... # All checks passed!Related Issues
TODO.md("Log cleanup - per-module log filters and default to DEBUG log levels")