fix(logging): give the journal the real severity of each line - #473
fix(logging): give the journal the real severity of each line#473ChuckBuilds wants to merge 1 commit into
Conversation
Everything this process writes to stdout reaches the journal as PRIORITY=6,
whatever the Python level was, because journald has nothing else to go on.
Measured on a live rig over 24 hours:
lines containing " - ERROR - " 55
lines containing " - WARNING - " 13
journald PRIORITY recorded 6, for every one of them
So `journalctl -p err -u ledmatrix` returns nothing while errors are being
logged, and `-p warning` likewise. Triage falls back to grepping message text,
which is slower and unreliable: during this audit a search for "oom" matched
the radar logging "zoom=9" twenty-four times and briefly looked like the OOM
killer had been firing.
systemd reads a leading "<N>" on each stdout line and takes it as the priority
(sd-daemon(3)), so a formatter that prefixes one costs no dependency. Every
line of a multi-line record is tagged, not just the first -- the journal splits
them, and an untagged continuation reverts to the default, which would leave
the body of a traceback filed as informational while its first line was an
error.
Applied only when JOURNAL_STREAM is set, which systemd sets for services whose
output it captures. Run from a terminal, in the emulator or under pytest the
prefixes would be literal noise, and the file handler keeps the plain
formatter for the same reason.
Mutation-checked three ways: prefixing unconditionally fails the
outside-systemd test, prefixing only the first line fails the multi-line test,
and mapping ERROR to 6 fails the level mapping. 39 tests pass across the
logging suites.
|
Warning Review limit reached
Next review available in: 30 minutes Limit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 5 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Superseded by #475, which carries this commit unchanged (cherry-picked with |
Found while surveying warnings on a live rig:
journalctl -p warning -u ledmatrixreturned "-- No entries --" for the last four hours. That seemed wrong, and it was.Every line reaches the journal as informational
Measured over 24 hours on the rig:
- ERROR -- WARNING -PRIORITYrecordedThe app writes to stdout and journald has nothing else to go on, so
journalctl -p err -u ledmatrixreturns nothing while errors are being logged.Triage then falls back to grepping message text — slower, and unreliable in a way that bit me during this audit: a search for
oommatched the radar loggingzoom=9twenty-four times, and for a few minutes it looked like the OOM killer had been firing. It hadn't.The fix
systemd reads a leading
<N>on each stdout line and takes it as the priority (sd-daemon(3)), so a formatter that prefixes one costs no dependency:Two details that matter:
JOURNAL_STREAMis set, which systemd sets for services whose output it captures. From a terminal, in the emulator, or under pytest the prefixes would be literal noise. The file handler keeps the plain formatter for the same reason.Verification
11 new tests, 39 passing across the logging suites.
Mutation-checked:
Related
This also makes the earlier work easier to act on: with real priorities, the SD-wear and log-volume reduction in #468 can be judged by
journalctl -p warningrather than by eye.🤖 Generated with Claude Code
https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW