Skip to content

feat: Datadog-style visual overhaul + parsing fixes (v0.2.0) - #6

Merged
JasonSatti merged 8 commits into
masterfrom
claude/clogs-v0.2-fixes-and-visuals
Jun 12, 2026
Merged

feat: Datadog-style visual overhaul + parsing fixes (v0.2.0)#6
JasonSatti merged 8 commits into
masterfrom
claude/clogs-v0.2-fixes-and-visuals

Conversation

@JasonSatti

@JasonSatti JasonSatti commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Full review pass over the formatter: fixes eight correctness bugs (several reachable from the README's own advertised use cases) and overhauls the visuals toward the Datadog Log Explorer aesthetic — a status-colored edge bar on every row, an adaptive column layout that eliminates fixed-width dead space, a truecolor palette with 256-color fallback, and an opt-in --badges chip style. Bumps to v0.2.0.

cat examples/example.log | clogs:

after

Correctness fixes

Bug Fix
Return values with a nested object as the last key broke the return block — a bare } line terminated the JSON buffer early Brace-depth tracking outside string literals replaces the bare-closer check; raw fallbacks also keep original indentation
CRITICAL rendered as a misaligned 8-char token in info blue Aligned red CRIT; long unknown levels truncate to the column width
Real CloudWatch runtime lines (tab-separated, no [Thread - x]) didn't parse Thread segment optional, tab separators handled
aws logs tail output didn't parse despite the README advertising it Event-timestamp prefix stripped before classification, then reclassified
Single-line return values (sam local invoke) rendered as dim passthrough Routed through the same held-slot machinery as multi-line returns
ddtrace banner suppressed as passthrough but rendered in full via INFO:ddtrace._monkey: Suppressed by message prefix regardless of wire format
Return-block dict values printed as Python repr ({'k': 'v'}) Rendered as JSON
python -m clogs.cli exited silently with no output __main__ guard + clogs/__main__.py (python -m clogs works)

Review follow-ups (c2f024b)

Addressed from external review:

  • WARN/CRIT/FATAL level shorthands map to warning/critical colors instead of falling back to info blue; runtime and stdlib regexes accept WARN.
  • aws logs tail-wrapped stdlib lines inherit the event timestamp instead of rendering an empty timestamp column (formats with their own timestamp keep it).
  • README startup wording matches the emitted ─── ↑ startup ─── rule.
  • run() docstring documents that color/badge styling is process-global formatter state (layout state resets per call).
  • from __future__ import annotations in test_cli.py — PEP 604 unions in signatures broke collection on Python 3.9.

Visuals

Row anatomy

  • Status-colored left-edge bar () on every log row — Datadog's row border. The bar and the gutter rule continue through wrapped messages and tag lines, so a multi-line record reads as one visually-bounded row.
  • Tags render inline on one wrapped line under instead of stacking one per line.
  • Error/warn message text is tinted to match its level, so those rows pop the way they do in Datadog.

Adaptive layout

  • The location column sizes itself to the longest location actually seen (capped at LOCATION_WIDTH), pre-scanned across the context buffer so the opening burst renders aligned.
  • The timestamp column collapses entirely for streams without timestamps (e.g. stdlib-only).

Palette

  • Truecolor Datadog-inspired palette when COLORTERM advertises truecolor/24bit; 256-color fallback otherwise. Critical reads hotter than error.
  • --badges (opt-in): uniform filled level chips with full words, Datadog status-chip style.
  • Block header/footer widths now match; the startup divider reads ─── ↑ startup ─── (it closes the section above it).

CLI behavior

  • --color auto/always/never — colors auto-disable when stdout isn't a TTY.
  • NO_COLOR is now spec-compliant: only a non-empty value disables color. ⚠️ Minor behavior change from v0.1, where NO_COLOR="" also disabled it.
  • Message wrapping honors COLUMNS via shutil.get_terminal_size.

Testing

166 tests passing (was 131). Coverage added for:

  • Nested-dict-as-last-key return blocks; indentation preserved in unparseable-buffer fallbacks
  • CRITICAL abbreviation, color, and column alignment across rows
  • Runtime lines without the thread segment; aws logs tail prefixed JSON/runtime/plain lines
  • Single-line return dicts at EOF vs mid-stream
  • ddtrace banner via the stdlib-logger format
  • Adaptive location width growth/cap; timestamp column collapse and re-pad
  • Badge chips: uniform width, centering, badge colors, --color never fallback
  • NO_COLOR spec behavior and explicit color override
  • Review follow-ups: WARN/FATAL color mapping, [WARN] runtime lines, tail event-timestamp inheritance for stdlib

Test plan

  • python -m pytest -q — 166 passed
  • ruff check clogs/ tests/ — clean
  • Smoke test against examples/example.log (plain + --badges, truecolor + 256-color)
  • Real CloudWatch-format runtime lines, nested return payloads, stdlib-only streams
  • pip install . and clogs --version / python -m clogs

Notes for review

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA

claude added 7 commits June 12, 2026 11:29
Bug fixes:
- Return values with a nested object as the last key no longer break the
  return block (brace-depth tracking replaces the bare '}' terminator);
  raw fallback now preserves original indentation
- CRITICAL renders as CRIT with its own color instead of a misaligned
  blue token; unknown long levels truncate to the column width
- Real CloudWatch runtime lines (tab-separated, no [Thread - x]) now parse
- aws logs tail event-timestamp prefixes are stripped before classification
- Single-line JSON return values (sam local invoke) get the return block
- ddtrace banner suppressed consistently (stdlib logger variant too)
- Return-block dict values render as JSON, not Python repr
- python -m clogs / python -m clogs.cli now work (__main__ guard + module)

Visuals:
- Status-colored left-edge bar on every log row, repeated on continuation
  lines (Datadog Log Explorer row border)
- Gutter rule extends through wrapped messages and tag lines
- Tags render inline on one wrapped line instead of stacking vertically
- Error/warn messages tinted to match their level
- Truecolor Datadog-inspired palette with 256-color fallback
- Adaptive layout: location column sizes to the longest location seen
  (capped at 22), timestamp column collapses when the stream has none
- Block headers and footers now the same width; startup divider clarified

CLI:
- --color auto/always/never; colors auto-disable when piped
- NO_COLOR now spec-compliant (non-empty value disables)
- Message wrapping honors COLUMNS via shutil.get_terminal_size

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
Renders levels as dark text on a level-colored background. The chip hugs
the word with one space per side so the text is centered by construction;
the level cell pads after the chip to keep columns aligned. Truecolor and
256-color variants, plain text when colors are disabled.

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
All chips are the same width (8 cols). Sized so the common 4-letter
levels (INFO, WARN, CRIT) center perfectly; 5-letter levels carry the
unavoidable half-character offset.

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
Mixed-length words (INFO=4, ERROR=5) can't all center in equal-width
chips on a character grid. Badge mode now uses uniform 3-letter labels
(INF, WRN, ERR, DBG, CRT — zerolog convention), giving identical chips
with dead-centered text. Non-badge mode keeps full level names.

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
Full words (INFO, ERROR) scan better than abbreviations and match
Datadog's actual status chips. Chips stay uniform width; the 5-letter
levels carry a half-character offset that's imperceptible in practice.

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
- Remove leftover unused variable, ambiguous names, unused import (ruff clean)
- argparse prog name so 'python -m clogs --version' says clogs
- Regenerate examples/after.png with continuous edge bars

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
@JasonSatti JasonSatti changed the title v0.2.0: parsing fixes + Datadog-style visual overhaul feat: Datadog-style visual overhaul + parsing fixes (v0.2.0) Jun 12, 2026
…ib, 3.9 test compat

- WARN/CRIT/FATAL level shorthands map to warning/critical colors instead
  of falling back to info blue; runtime and stdlib regexes accept WARN
- aws logs tail-wrapped stdlib lines inherit the event timestamp instead
  of rendering an empty timestamp column
- from __future__ import annotations in test_cli.py — PEP 604 unions in
  signatures broke collection on Python 3.9
- README startup wording matches the emitted '↑ startup' rule
- run() docstring documents process-global color/badge styling state

https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA
@JasonSatti
JasonSatti merged commit aeac5b5 into master Jun 12, 2026
@JasonSatti
JasonSatti deleted the claude/clogs-v0.2-fixes-and-visuals branch June 12, 2026 19:05
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.

2 participants