Skip to content

feat: per-line colour coding in the styled log viewer - #3

Open
s950tx16wasr10 wants to merge 1 commit into
mainfrom
feat/colorize-log-viewer
Open

feat: per-line colour coding in the styled log viewer#3
s950tx16wasr10 wants to merge 1 commit into
mainfrom
feat/colorize-log-viewer

Conversation

@s950tx16wasr10

Copy link
Copy Markdown

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.log for 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 optional GAME- 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:

Category Class Visual
ATTACK, VICTIM log-attack red
SAY, WHISPER, RADIO log-say green
EMOTE, RADIO_EMOTE, SPEECH_INDICATORS log-emote green italic
DSAY, DEAD log-dead purple italic
OOC log-ooc light blue
ADMIN, ASAY log-admin blue, semibold
ADMINPRIVATE log-adminprivate grey italic
ACCESS log-access grey
PRAY, VOTE, GAME log-event amber
PDA, CHAT, COMMENT, TELECOMMS log-chat teal
MECHA, SHUTTLE, TRANSPORT log-mechanism brown
ECON, ECONOMY, OWNERSHIP log-econ green
TOPIC, SQL log-system muted grey
-censored(...)- log-censored grey italic

Tested against light-dark with the existing color-scheme: light dark meta on the page. Each colour was picked to stay readable on both #f3f6f7 and #1c1d1f backgrounds.

Tests

5 new tests in route::tests:

  • line_class_matches_categories covers every category in the table above plus default fallback
  • colorize_line_wraps_categorized_lines_only confirms the default-class shortcut
  • viewer_page_colorizes_attack_line confirms an attack line ends up in <span class="log-attack"> in the rendered page
running 17 tests
test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

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.
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.

1 participant