feat: Datadog-style visual overhaul + parsing fixes (v0.2.0) - #6
Merged
Conversation
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
Critical was a lighter pink than error, reading as less severe. 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
Merged
7 tasks
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
--badgeschip style. Bumps to v0.2.0.cat examples/example.log | clogs:Correctness fixes
}line terminated the JSON buffer earlyCRITICALrendered as a misaligned 8-char token in info blueCRIT; long unknown levels truncate to the column width[Thread - x]) didn't parseaws logs tailoutput didn't parse despite the README advertising itsam local invoke) rendered as dim passthroughINFO:ddtrace._monkey:{'k': 'v'})python -m clogs.cliexited silently with no output__main__guard +clogs/__main__.py(python -m clogsworks)Review follow-ups (
c2f024b)Addressed from external review:
WARN/CRIT/FATALlevel shorthands map to warning/critical colors instead of falling back to info blue; runtime and stdlib regexes acceptWARN.aws logs tail-wrapped stdlib lines inherit the event timestamp instead of rendering an empty timestamp column (formats with their own timestamp keep it).─── ↑ startup ───rule.run()docstring documents that color/badge styling is process-global formatter state (layout state resets per call).from __future__ import annotationsintest_cli.py— PEP 604 unions in signatures broke collection on Python 3.9.Visuals
Row anatomy
▎) 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.↳instead of stacking one per line.Adaptive layout
LOCATION_WIDTH), pre-scanned across the context buffer so the opening burst renders aligned.Palette
COLORTERMadvertisestruecolor/24bit; 256-color fallback otherwise. Critical reads hotter than error.--badges(opt-in): uniform filled level chips with full words, Datadog status-chip style.─── ↑ startup ───(it closes the section above it).CLI behavior
--color auto/always/never— colors auto-disable when stdout isn't a TTY.NO_COLORis now spec-compliant: only a non-empty value disables color.NO_COLOR=""also disabled it.COLUMNSviashutil.get_terminal_size.Testing
166 tests passing (was 131). Coverage added for:
CRITICALabbreviation, color, and column alignment across rowsaws logs tailprefixed JSON/runtime/plain lines--color neverfallbackNO_COLORspec behavior and explicit color overrideWARN/FATALcolor mapping,[WARN]runtime lines, tail event-timestamp inheritance for stdlibTest plan
python -m pytest -q— 166 passedruff check clogs/ tests/— cleanexamples/example.log(plain +--badges, truecolor + 256-color)pip install .andclogs --version/python -m clogsNotes for review
clogs/formatter.py(adaptive layout, bar/continuation rendering) andContextTracker._scan_json_depthincontext.py.examples/after.pngis regenerated from the new output.https://claude.ai/code/session_01MgMZvBpttCRAZhsHRhNtBA