feat: add structured logging and DEBUG flag - #11
Conversation
d23155a to
6b7bf0d
Compare
68e941e to
96f7dc3
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11 +/- ##
==========================================
+ Coverage 93.65% 94.60% +0.94%
==========================================
Files 34 34
Lines 2933 3170 +237
Branches 198 201 +3
==========================================
+ Hits 2747 2999 +252
+ Misses 140 123 -17
- Partials 46 48 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6b7bf0d to
52e7212
Compare
ca6dbe2 to
0e6bae7
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces structured, opt-in debug logging across the CLI entrypoints and the briefing service, controlled by a new Settings.debug flag derived from the DEBUG environment variable. The goal is to make runs observable (start/end, per-location actions, RSS/LLM diagnostics) while keeping default output concise.
Changes:
- Add
debug: booltoSettingsand parseDEBUGenv var truthy values. - Add CLI logging initialization and replace user-facing
printoutput with structured logs + top-level exception logging. - Add service-level logs for RSS fetches, staleness warnings, skip reasons, and LLM retry/validation diagnostics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| weather_briefing/service.py | Adds structured service logs around RSS ingestion, skip conditions, and LLM retry/validation flow. |
| weather_briefing/config.py | Adds Settings.debug sourced from DEBUG env var. |
| weather_briefing/cli.py | Adds logging configuration, run lifecycle logs, and top-level exception logging. |
| tests/test_service.py | Asserts consecutive-failure context is attached to raised exceptions via __notes__. |
| tests/test_config.py | Adds coverage for DEBUG truthy parsing (including quoted values). |
| tests/test_cli.py | Adds coverage for idempotent logging configuration and main() error logging. |
| README.md | Documents stderr logging and DEBUG=true diagnostics behavior. |
| env.example | Documents the DEBUG environment variable. |
| docs/design.md | Documents the intended logging behavior and rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add setup with configurable DEBUG level via env var - Log briefing lifecycle: run start, location processing, article counts, stale source warnings, publish results - Log LLM retry attempts at DEBUG level - Log full tracebacks on errors via - All messages go to stderr with timestamps and level prefixes
0e6bae7 to
db80134
Compare
db80134 to
a5cb78a
Compare
|
Warning Review limit reached
Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthrough新增 DEBUG 配置及 stderr 日志说明;CLI 统一配置日志、记录运行进度并处理未捕获异常;BriefingService 增加 RSS、发布、LLM 重试和连续失败诊断日志,测试覆盖相关行为。 ChangesStructured logging and diagnostics
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as weather_briefing.cli
participant Settings as Settings.from_env
participant Service as BriefingService
participant stderr
CLI->>Settings: 读取 DEBUG 配置
CLI->>CLI: 配置 stderr logging
CLI->>Service: 执行 briefing run
Service-->>CLI: 返回发布内容或 None
Service->>stderr: 输出 RSS、LLM 与失败诊断
CLI->>stderr: 输出运行状态或未捕获异常
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
a5cb78a to
2ef418b
Compare
2ef418b to
b7550a9
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_cli.py`:
- Around line 327-336: Fix the eagerly evaluated self-referencing return
annotations in _FakeAsyncClient.__aenter__ and FakeState.__enter__ by quoting
each class name as a forward reference. Preserve the existing context-manager
behavior and signatures otherwise so the test module imports successfully.
- Line 387: Rename the unused lambda parameter in the monkeypatch for
httpx.AsyncClient to a descriptive, non-ambiguous name, while preserving the
existing _FakeAsyncClient construction and behavior.
In `@weather_briefing/cli.py`:
- Around line 82-98: The _configure_logging function currently enables DEBUG on
the root logger, exposing verbose httpx/httpcore request metadata. Keep
application debug logging while explicitly pinning the httpx and httpcore logger
levels to a safer threshold, or apply equivalent redaction before setting
logging.root to DEBUG; ensure API keys, bearer tokens, and URLs cannot be
emitted to stderr.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8d0f07df-fd83-427f-b660-7660c0210831
📒 Files selected for processing (9)
README.mddocs/design.mdenv.exampletests/test_cli.pytests/test_config.pytests/test_service.pyweather_briefing/cli.pyweather_briefing/config.pyweather_briefing/service.py
(API keys, headers, URLs)
Summary
Add structured lifecycle logging with useful
INFOoutput by default and opt-inDEBUGdiagnostics.Changes
Logging configuration
Settings.debug, controlled byDEBUG=1,true, oryesINFObefore runtime settings are parsed, with explicitdatefmtremoving millisecondsenv.example, the README, and the design contractLifecycle logging
WARNINGFailure handling
Debug diagnostics
When
DEBUG=true, additionally log:Usage
Review fixes
datefmt="%Y-%m-%d %H:%M:%S"to log formatter to avoid milliseconds_summarizeto include actual attempt countmain()Summary by CodeRabbit
New Features
DEBUG=truesupport for detailed diagnostics, including RSS and LLM processing.Bug Fixes