Overview
This server receives logs (POST), stores them in logs.json, pushes realtime updates over WebSocket, and can archive logs into timestamped files in archives/. When a log containing "shutdown" is received, the server auto-archives the current logs and clears them.
Important files & folders
logs.json— current in-memory/persisted logs (JSON array)archives/— archived snapshots namedlogs-YYYY-MM-DDTHH-MM-SS-msZ.jsonlogs.html,logs_list.html,docs.html— UI pages
Endpoints
POST /log— body:{ "log": "your log text" }. Adds a log, persists to disk, broadcasts via WebSocket. If the log text containsshutdown(case-insensitive) the server automatically archives current logs and clears them.GET /logs— serve live logs page (logs.html)GET /logs/data— returns current logs as JSONGET /logs/list— UI page that lists archived snapshots with download linksGET /logs/archives— returns JSON array of archive filenamesGET /logs/download/:name— download a specific archivePOST /logs/clear— archive current logs and clear themPOST /logs/archives/clear— delete all archivesDELETE /logs/archives/:name— delete a single archive fileGET /docs— this documentation page
WebSocket
Connect to the same host (ws:// or wss://) to receive an initial dump of logs.json and live pushes of new log entries. The server emits small JSON messages: either an array of new logs or control objects like { cleared: true, archived: 'filename' }.
Examples
Send a log via curl:
curl -X POST -H "Content-Type: application/json" -d '{"log":"Player: Shutdown"}' http://localhost:3000/log
Fetch archives list:
curl http://localhost:3000/logs/archives
Download an archive (browser or curl):
curl -O http://localhost:3000/logs/download/logs-2025-01-01T12-00-00-000Z.json
Behavior notes
- Auto-archive triggers when any posted log contains the word "shutdown" (case-insensitive).
- Archives are simple JSON arrays — they contain the exact entries from
logs.jsonat archive time. - Disk operations are synchronous for simplicity; this is fine for development but consider async handling for production/high-throughput.
Developer tips
- To add fields (timestamps, levels) consider sending structured JSON objects instead of plain strings and updating UI code accordingly.
- Backup your
archives/if logs are important — deletion endpoints are destructive. - Use the
/logs/dataand WebSocket to drive a richer UI or post-processing pipeline.