Add logs (with colour) to web UI #38

Closed
opened 2026-07-07 17:20:15 +01:00 by danny · 4 comments
danny commented 2026-07-07 17:20:15 +01:00 (Migrated from gitlab.keyop.co.uk)

It would be good to be able to view live logs from the web UI, including colourised log entries based on levels.

It would be good to be able to view live logs from the web UI, including colourised log entries based on levels.
danny commented 2026-07-07 17:20:46 +01:00 (Migrated from gitlab.keyop.co.uk)

changed the description

changed the description
Collaborator

Plan:

  • internal/log: add a fixed-capacity, overwrite-oldest ring buffer capturing every log record (time/level/message/attrs) as it's handled, wrapping the existing tint handler rather than replacing it - stderr output is unaffected. Exposed via log.EnableBuffer(capacity)/log.Entries(sinceSeq).
  • New web_ui.log_buffer_lines config field (default 1000), following the same default/validate pattern as the other web_ui.* int fields.
  • setupLogging enables the buffer only when the web UI itself is enabled - no memory/CPU cost otherwise.
  • New GET /logs page + GET /api/logs?since=<seq> endpoint (session-gated, same as every other page) - the frontend polls with a cursor so it only fetches new entries each time, not the whole buffer.
  • Colour comes from the frontend mapping each entry's level field to a CSS class (not by trying to convert tint's ANSI terminal codes to HTML) - cleaner and ties into this project's existing light/dark CSS variables.
  • Matches this codebase's established polling convention (no WebSocket/SSE used anywhere else here) - auto-scrolls to the bottom as new entries arrive, pausing if you've scrolled up to read history.

Will post again once a PR is up.

Plan: - `internal/log`: add a fixed-capacity, overwrite-oldest ring buffer capturing every log record (time/level/message/attrs) as it's handled, wrapping the existing tint handler rather than replacing it - stderr output is unaffected. Exposed via `log.EnableBuffer(capacity)`/`log.Entries(sinceSeq)`. - New `web_ui.log_buffer_lines` config field (default 1000), following the same default/validate pattern as the other `web_ui.*` int fields. - `setupLogging` enables the buffer only when the web UI itself is enabled - no memory/CPU cost otherwise. - New `GET /logs` page + `GET /api/logs?since=<seq>` endpoint (session-gated, same as every other page) - the frontend polls with a cursor so it only fetches new entries each time, not the whole buffer. - Colour comes from the frontend mapping each entry's `level` field to a CSS class (not by trying to convert tint's ANSI terminal codes to HTML) - cleaner and ties into this project's existing light/dark CSS variables. - Matches this codebase's established polling convention (no WebSocket/SSE used anywhere else here) - auto-scrolls to the bottom as new entries arrive, pausing if you've scrolled up to read history. Will post again once a PR is up.
Collaborator

PR #82 is up, CI green - link: #82

PR #82 is up, CI green - link: https://forgejo.keyop.co.uk/keyop-go/nfq_forwarder/pulls/82
danny closed this issue 2026-07-09 17:11:46 +01:00
Collaborator

Merged via #82 (merge commit 97ee832), released as v1.2.0 - https://forgejo.keyop.co.uk/keyop-go/nfq_forwarder/releases/tag/v1.2.0 (confirmed real, all four package formats + checksums attached).

Merged via #82 (merge commit `97ee832`), released as **v1.2.0** - https://forgejo.keyop.co.uk/keyop-go/nfq_forwarder/releases/tag/v1.2.0 (confirmed real, all four package formats + checksums attached).
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
keyop-go/nfq_forwarder#38
No description provided.