add: solvent logs — tail and filter the structured event log#43
Conversation
- solvent logs show last 20 log lines (human-readable) - solvent logs -n 50 show last 50 lines - solvent logs -f live-follow like tail -f (0.5s poll) - solvent logs --job filter by job ID prefix - solvent logs --stage filter by pipeline stage name - solvent logs --json raw JSON output for scripting - solvent logs --path print the log file path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SGjM79GJpSksy9wSSBa7e6
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db77d69e3a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _fmt_margin(m: float) -> str: | ||
| return f"{m * 100:.1f}%" |
There was a problem hiding this comment.
Stop multiplying percentage margins again
When a booked job is logged, StageRunner._emit stores margin_actual from actual_margin_pct, and service.reconcile_cogs already computes that field on a 0–100 percentage scale. Formatting it here as m * 100 makes normal human log output report values like 8000.0% for an 80% margin, which undermines the new operator-facing financial log view.
Useful? React with 👍 / 👎.
| if not follow: | ||
| lines = _tail_lines(path, max(n * 4, 200)) # over-fetch then filter |
There was a problem hiding this comment.
Apply job and stage filters before truncating the log
When --job or --stage is used, this only reads the most recent max(n * 4, 200) physical log lines before filtering, so an active install can print (no matching entries) for a valid job or stage as soon as more than that many unrelated events have been appended. The advertised filter should either scan/filter the log before taking the last n matches, or clearly restrict itself to the recent physical tail.
Useful? React with 👍 / 👎.
Summary
Completes the operator visibility triangle alongside
solvent statusandsolvent jobs.solvent logs— show last 20 lines ofdata/solvent.log(human-readable columnar)solvent logs -n 50— show last N linessolvent logs -f/--follow— live-follow liketail -f(0.5 s poll, Ctrl-C exits)solvent logs --job <id>— filter by job ID prefix matchsolvent logs --stage <stage>— filter by pipeline stage namesolvent logs --json— raw JSON output for scripting/monitoringsolvent logs --path— print the log file path and exitPure stdlib — no new dependencies.
Test plan
python3 -m pytest tests/test_logs.py -v→ 29 passedpython3 -m pytest -q→ 414 passed, 6 skippedsolvent logson empty log → "(no log entries)"solvent logs --json→ valid JSON per linesolvent logs --stage fulfill→ only fulfill entriessolvent logs -f→ live output on new events🤖 Generated with Claude Code
https://claude.ai/code/session_01SGjM79GJpSksy9wSSBa7e6
Generated by Claude Code