feat: per-line colour coding in the styled log viewer - #3
Open
s950tx16wasr10 wants to merge 1 commit into
Open
Conversation
Each scrubbed log line is now classified by its category prefix (ATTACK, SAY, ADMIN, ACCESS, etc.) and wrapped in a span with a class the stylesheet tints. Attack lines render red, say/whisper green, admin blue, censored grey-italic, and so on, in both light and dark mode. The classifier reads the [timestamp] CATEGORY: shape, strips the optional GAME- prefix, and falls back to a default class for unrecognised categories or non-log-shaped lines (like the parser's own -censored(...)- markers, which get their own muted italic style). Default-class lines are returned without a span wrapper to keep the HTML small for long files. 5 new tests in route::tests covering all major categories, the censored special-case, the default fallback, and that viewer_page actually emits the spans.
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.
What
Each scrubbed log line is now classified by its category prefix and wrapped in a
<span>with a class the stylesheet tints. ATTACK red, SAY green, ADMIN blue, ACCESS grey, censored grey-italic, etc. Both light and dark themes.Why
The viewer was monochrome. With colour, scanning a 100k-line
game.logfor the part where things went wrong takes seconds instead of minutes - admin actions stand out, combat is obvious, dead-chat doesn't blend with normal say.How
line_class()reads[timestamp] CATEGORY:from each line, strips the optionalGAME-prefix, and maps the category to a CSS class. Default-class lines (continuation lines, parser-generated censor markers that are already wrapped, anything off-shape) skip the span to keep HTML lean for long files.Mapping:
Tested against light-dark with the existing
color-scheme: light darkmeta on the page. Each colour was picked to stay readable on both#f3f6f7and#1c1d1fbackgrounds.Tests
5 new tests in
route::tests:line_class_matches_categoriescovers every category in the table above plus default fallbackcolorize_line_wraps_categorized_lines_onlyconfirms the default-class shortcutviewer_page_colorizes_attack_lineconfirms an attack line ends up in<span class="log-attack">in the rendered page