refactor(logging): consolidate multi-line log blocks and quiet third-party loggers#289
Open
spalen0 wants to merge 1 commit into
Open
refactor(logging): consolidate multi-line log blocks and quiet third-party loggers#289spalen0 wants to merge 1 commit into
spalen0 wants to merge 1 commit into
Conversation
…party loggers Stat/header output emitted one logger call per line, repeating the `[ts] LEVEL name:` prefix on every row. Combine each consecutive same-level block into a single record with embedded newlines so the prefix shows once while line breaks stay readable. Touches gauntlet, compound, usdai, infinifi, ethena, origin (lrt-pegs), safe, bad-debt, and yearn shadow-debt paths. Add toggleable suppression of noisy third-party loggers (web3, urllib3, requests, …) in utils/logger.py via `quiet_dependency_loggers()`: capped at WARNING by default so they don't bury our own output, applied on import so every protocol subprocess inherits it. Controlled by the new DEP_LOG_LEVEL env var (set DEBUG/TRACE to bring the chatter back). Also called from the two root-configuring entrypoints (automation CLI, alert_large_flows) which use plain `logging.basicConfig`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Mirrors the logging cleanup just done in
liquidity-monitoring. Two related changes — what gets logged is unchanged, only how it's grouped — plus one new opt-in knob.1. Consolidate multi-line log blocks
Stat/header output was emitted as one
logger.*call per line, so the[ts] LEVEL name:prefix repeated on every row. Each consecutive same-level block is now built as one string and emitted in a single record, with embedded\nkeeping the readable line breaks.Touched:
utils/gauntlet.py,protocols/compound/collateral.py,protocols/usdai/main.py,protocols/infinifi/main.py,protocols/ethena/ethena.py,protocols/lrt-pegs/origin_protocol.py,protocols/safe/main.py,protocols/bad-debt/bad-debt-trigger.py,protocols/yearn/check_shadow_debt.py.Only same-level runs were merged; lines split by real logic or at different levels were left alone.
2. Toggleable suppression of third-party logs
utils/logger.pygainsquiet_dependency_loggers(), which caps noisy library loggers (web3, urllib3, requests, aiohttp, asyncio, websockets, hpack, httpx, httpcore, eth, ens) atWARNINGindependently of our own level — soLOG_LEVEL=DEBUGno longer drowns inweb3.manager.RequestManager Making request.... SetDEP_LOG_LEVEL=DEBUG(orTRACE) to bring that chatter back.It's applied on import (every protocol runs in its own subprocess that imports
utils.logger), and also called explicitly from the two entrypoints that configure the root logger vialogging.basicConfig—automation/__main__.pyandprotocols/yearn/alert_large_flows.py.Testing
uv run ruff format+uv run ruff check: cleanuv run pytest: 533 passed, 4 skippedDEP_LOG_LEVELboth directions: web3 DEBUG suppressed by default underLOG_LEVEL=DEBUG, re-surfaced whenDEP_LOG_LEVEL=DEBUG.🤖 Generated with Claude Code