Skip to content

refactor(logging): consolidate multi-line log blocks and quiet third-party loggers#289

Open
spalen0 wants to merge 1 commit into
mainfrom
logging-consolidation
Open

refactor(logging): consolidate multi-line log blocks and quiet third-party loggers#289
spalen0 wants to merge 1 commit into
mainfrom
logging-consolidation

Conversation

@spalen0

@spalen0 spalen0 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

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 \n keeping 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.py gains quiet_dependency_loggers(), which caps noisy library loggers (web3, urllib3, requests, aiohttp, asyncio, websockets, hpack, httpx, httpcore, eth, ens) at WARNING independently of our own level — so LOG_LEVEL=DEBUG no longer drowns in web3.manager.RequestManager Making request.... Set DEP_LOG_LEVEL=DEBUG (or TRACE) 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 via logging.basicConfigautomation/__main__.py and protocols/yearn/alert_large_flows.py.

Testing

  • uv run ruff format + uv run ruff check: clean
  • uv run pytest: 533 passed, 4 skipped
  • Verified DEP_LOG_LEVEL both directions: web3 DEBUG suppressed by default under LOG_LEVEL=DEBUG, re-surfaced when DEP_LOG_LEVEL=DEBUG.

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant