The viewer parses a four-line sample, filters recognized levels and literal message text, and adds one neighboring line on either side when context is enabled. ERROR only gives one primary match; adding context gives three visible rows. An unrecognized stack line stays UNKNOWN rather than inheriting ERROR from the line above it.

Define exactly what the level means
Recognize only the exact uppercase prefixes [DEBUG], [INFO], [WARN], and [ERROR] at the start of a line. The remaining characters are the message. Keep the complete original line separately.
A line without one of those anchored prefixes is UNKNOWN. Thus line three is UNKNOWN, not automatically ERROR because it follows an error line. Text such as "prefix [ERROR] note" is also UNKNOWN because the level token is not at the start.
Split CRLF or LF line endings for inspection without rewriting the raw input field. One final newline terminates the last line rather than adding an extra event. Preserve interior blank lines as UNKNOWN records, including their original positions. An empty input has no line records.
Apply level and search as one condition
Use level-toggle buttons for DEBUG, INFO, WARN, ERROR, and UNKNOWN, initially all selected. Search is a case-insensitive literal substring of the message: the full raw line serves as the message for UNKNOWN. An empty query matches every message, while no selected levels yields no matches.
A record is a primary match only if its level is selected AND its message contains the query. Search text is not a regular expression or executable query.
| Selected levels and query | Primary matches |
|---|---|
| ERROR; empty query | Line 2, count 1 |
| All levels; worker | Line 3, count 1 |
| ERROR; worker | None, count 0 |
| All levels; r1 | Line 2, count 1 |
The third case is essential. The nearby UNKNOWN line containing worker does not make the ERROR line match worker. Context can explain a result, but it does not satisfy its filter predicate.
Add context without changing the count
Show Context adds one original line before and after each primary match. For the ERROR-only case, the visible set becomes lines one, two, and three:
| Original line | Classification in the view |
|---|---|
| 1 | Context only |
| 2 | Primary match |
| 3 | Context only |
Report one primary match and three visible rows. Line four lies outside line two's ±1 context window. Context rows can appear even when their level is unchecked, since their purpose is to show the neighboring original record.
Combine overlapping context windows by original line identity, remove duplicates, and display the union in original order. If all four example lines are primary matches, their windows still produce four visible rows, not repeated copies. A primary match stays labeled matched even if it also belongs to another match's context window.
Keep edits, filters, and clearing separate
Use an Inspect action to parse and validate a pasted excerpt. Afterward, changing level buttons, query, or Show Context recomputes the view from those same line records, clearing any outdated detail selection.
Reset Filters selects all levels, clears the query, disables Show Context, and clears selection while retaining the raw input and inspected records. Clear Input empties the raw field, records, results, counts, errors, and selection. Editing the raw input invalidates the old records until Inspect succeeds again.
Limit input to 20,000 UTF-16 code units and 500 line records after the final-newline rule. Reject an oversized excerpt with a text error and no retained filter result; do not silently truncate it. Keep log text selectable and preserve spaces using an appropriate text presentation.
Render records and details as literal text with textContent. An example line containing <img src=x> must show those characters rather than create an image or link. The local viewer uses literal text output; keep host and sharing conditions in mind when choosing which excerpt to show.
The helper has no automatic secret detection, redaction, saved history, file watching, upload, or export. Keep the source excerpt in its authorized native record rather than treating the filtered view as a complete replacement.
Try the four-line sample
The supplied lines are “[INFO] started”, “[ERROR] failed request r1”, “ at worker:12”, and “[INFO] ended”. Press Inspect excerpt, choose Errors only, and turn on context. The result labels line 2 MATCH and lines 1 and 3 CONTEXT ONLY. Search for worker while ERROR remains the only selected level and there are no matches: a nearby stack line cannot satisfy the error line’s predicate.
Keep the original excerpt with your investigation. Enter an original line number and press Inspect line to read it with its immediate neighbors. This detail view does not alter match counts. Reset filters keeps the inspected text; Clear input removes it and every derived result.
Copy this prompt
Build a paste-only HTML log inspector for this exact original sample: [INFO] started; [ERROR] failed request r1; two leading spaces followed by at worker:12; [INFO] ended. Put each on a separate line in an editable textarea. Parse only anchored uppercase [DEBUG], [INFO], [WARN], [ERROR] prefixes. Every other line is UNKNOWN; retain complete raw text and original one-based line IDs. Split LF/CRLF, preserve interior blank lines, and remove only one trailing terminator rather than treating it as another event.
Provide Inspect excerpt, native per-level toggle buttons, All levels, Errors only, a literal case-insensitive message search and a context toggle. Primary match requires selected level AND substring. Context adds ±1 original neighbor, deduplicated and sorted, without increasing match count. Label every displayed line MATCH or CONTEXT ONLY. ERROR-only gives line 2; with context show lines 1–3, one match and three rows. ERROR plus worker gives zero.
A labeled original-line-number field and Inspect line action display raw neighbors separately. Raw edits invalidate parsed results. Reset filters retains input/records; Clear input clears everything. Reject over 20000 UTF-16 units or 500 records with no silent truncation. Render all log content through textContent, including literal markup. No secret detection, upload, tailing or export claims.
Return one complete HTML file. Put the excerpt editor and level buttons above the numbered result rows. Keep the primary-match count distinct from added context rows. Use readable wrapped log text, labeled search and line-number fields, and controls that fit a phone. A filter change must clear the previous inspected-line selection.
Preserve the evidence behind the filter
Keep the original authorized log and its line references in the incident record. Use the filtered view to point a colleague to the exact match and its neighboring evidence. For a troubleshooting explanation using a sanitized excerpt, NOS can render the HTML with matched and context-only rows clearly separated. Begin with the one-match, three-row example so surrounding context is never mistaken for additional errors.