Skip to content

Add the FOG 1.6 Log Viewer page over the fog-node log file - #213

Merged
fog-workflows[bot] merged 1 commit into
masterfrom
feat/log-viewer
Nov 17, 2026
Merged

fog-workflows[bot] merged 1 commit into
masterfrom
feat/log-viewer

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Closes #209. Map: #155. Builds on #208 (PR #211, the log file) and #207 (PR #212).

What

  • GET /logviewer and POST /api/v1/log/tail show the end of the fog-node log in the browser, under Logging, as the FOG 1.6 Log Viewer does.
  • The gate is setting.read, as 1.6 gates the viewer under settings (Tom, 2026-11-17). There is no new permission.
  • Controls: a File select, a Lines select (10 to 1000, default 100), Reverse order, and Pause Reload / Resume Reload. A 10-second poll stops on pagehide.

File access, a security boundary

  • Only fog-node.log and .1 to .5 can be read. They are matched by exact name and must be regular files (lstat, bigint). A symlink or a folder is never listed.
  • The server builds the path. The client value is only a lookup key.
  • After the open, fstat dev/ino must match the listed file, so a file swapped in between answers 400. The descriptor is closed on every path.
  • A missing file answers 200 with []. Any other error answers 500 with a fixed message, and the detail goes to the server log only.
  • Lines render with textContent.

Tail

  • It reads backwards in 4096-byte chunks, up to 4 MiB.
  • It splits on the newline byte before it decodes, so no UTF-8 character is split.
  • It drops a partial first line.
  • Beyond the brief: it also stops early if the file shrinks during a read, and drops the line at the cut.

Shared constants

  • api/lib/file-logger.js now exports FILE, KEEP and FALLBACK_DIR. config/log.js and the viewer both use them.
  • api/lib/log-viewer.js holds the line choices and the read bounds.

Tests

  • npm test: 611 passing. npm run test:ui and npm run test:ui:prod: all checks pass.
  • New: test/integration/log-viewer.test.js and test/helpers/log-tail.test.js cover the gate, traversal, the symlink and swapped-file cases, the line values, the UTF-8 boundary, the 4 MiB cap, and the sentinel.
  • New smoke check: tools/smoke/checks/log-viewer.js. It covers the <img> line rendered as text, Pause with a fake clock, and Reverse.
  • Each test was shown red:
    • removing lstat (alone) fails the symlink test;
    • removing the dev/ino compare fails the stale-entry test;
    • switching textContent to innerHTML fails the smoke check;
    • removing the menu entry fails the sidebar check.

Review

  • An executor built it on Sonnet.
  • Spec and standards reviews ran on Opus, two rounds each, and the last standards verdict was CLEAN.

🤖 Generated with Claude Code

Adds GET /logviewer and POST /api/v1/log/tail: the end of the fog-node
log (#208) in the browser, under Logging, as the FOG 1.6 Log Viewer.
Gated by setting.read, as 1.6 gates it under settings (Tom, 2026-11-17).

- Only fog-node.log and .1 to .5 are readable, by exact name, and only
  as regular files (lstat, bigint). The server builds the path; after
  the open, fstat dev/ino must match the listed file, so a file swapped
  for a symlink answers 400. The descriptor is closed on every path.
- The tail reads backwards in 4096-byte chunks, at most 4 MiB, splits on
  the newline byte before decoding (no split UTF-8 characters), and
  stops early if the file shrinks mid-read.
- Lines 10 to 1000 (default 100), reverse order, a 10-second poll with
  Pause and Resume, rendered with textContent.
- The log file name, rotation count and fallback folder are exported
  from api/lib/file-logger.js and shared by config/log.js and the viewer.

Closes #209

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge November 17, 2026 19:45
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit 02b64c7 Nov 17, 2026
5 of 6 checks passed
@fog-workflows
fog-workflows Bot deleted the feat/log-viewer branch November 17, 2026 20:06
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.

Add the FOG 1.6 Log Viewer page over the fog-node log file

1 participant