feat(error-log): bounded in-memory WARN/ERROR ring buffer (VS-7) #19

Merged
David merged 2 commits from feat/error-log-buffer-vs-7 into main 2026-05-17 14:44:23 +02:00
Owner

Summary

Replaces the empty ServerErrors reply with a real ring-buffer-backed list of recent WARN / ERROR tracing events.

Changes

  • New crates/meshcentral-web/src/error_buffer.rs (1024-entry bounded VecDeque + tracing_subscriber::Layer capture).
  • ServerErrors reads state.error_buffer.snapshot() and renders one line per entry; ServerClearErrorLog clears the ring.
  • ServerConfig grows an optional error_buffer so the binary can pass the same buffer the tracing layer writes to.
  • meshcentral/src/main.rs::init_tracing switches from fmt().init() to a layered Registry that combines the env filter, the fmt layer (stderr), and the error-buffer layer.
  • 4 new unit tests.

Test plan

  • cargo test -p meshcentral-web --lib error_buffer (4/4 passing).
  • cargo check --workspace clean.
  • Reviewer: in the SPA, trigger a server-side warning (e.g. an invalid mesh CRUD payload) then open the "Server errors" tab.

Closes VS-7.

## Summary Replaces the empty `ServerErrors` reply with a real ring-buffer-backed list of recent WARN / ERROR tracing events. ## Changes - New `crates/meshcentral-web/src/error_buffer.rs` (1024-entry bounded VecDeque + `tracing_subscriber::Layer` capture). - `ServerErrors` reads `state.error_buffer.snapshot()` and renders one line per entry; `ServerClearErrorLog` clears the ring. - `ServerConfig` grows an optional `error_buffer` so the binary can pass the same buffer the tracing layer writes to. - `meshcentral/src/main.rs::init_tracing` switches from `fmt().init()` to a layered Registry that combines the env filter, the fmt layer (stderr), and the error-buffer layer. - 4 new unit tests. ## Test plan - [x] `cargo test -p meshcentral-web --lib error_buffer` (4/4 passing). - [x] `cargo check --workspace` clean. - [ ] Reviewer: in the SPA, trigger a server-side warning (e.g. an invalid mesh CRUD payload) then open the "Server errors" tab. Closes VS-7.
feat(error-log): bounded in-memory WARN/ERROR ring buffer (VS-7)
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Failing after 7s
e3f33815ce
`ControlIn::ServerErrors` returned `data: None` regardless of how many warnings or errors the server had emitted, because there was no capture path. `ControlIn::ServerClearErrorLog` likewise no-op'd because there was nothing to clear.

Adds `crates/meshcentral-web/src/error_buffer.rs` with a 1024-entry bounded ring buffer (drops oldest on overflow) and a `tracing_subscriber::Layer` impl that captures every WARN and ERROR event into it. `ServerErrors` now serialises the snapshot as one entry per line (`<ts_ms> <LEVEL> <target>: <message>`); `ServerClearErrorLog` calls `buffer.clear()`. Both remain site-admin gated.

Wiring: `ServerConfig` grows a `error_buffer: Option<ErrorBuffer>` (passed by the binary so the layer + the dispatcher share the same ring); `AppState::error_buffer` is the read side. `meshcentral/src/main.rs::init_tracing` switches to the `Registry` + layered subscriber and returns the buffer so the binary can thread it into `start`.

Four unit tests cover record / snapshot, clear, capacity overflow, and the layer's WARN+ERROR-only filter.

#VS-7 State Done
Merge branch 'main' into feat/error-log-buffer-vs-7
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Failing after 3s
Create release / Create release from merged PR (pull_request) Has been skipped
ae33371a97
# Conflicts:
#	crates/meshcentral-web/Cargo.toml
David merged commit acd0fe23b2 into main 2026-05-17 14:44:23 +02:00
David deleted branch feat/error-log-buffer-vs-7 2026-05-17 14:44:23 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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
psa-systems/vervain-server!19
No description provided.