A read-only local log tail and search viewer for SCORPIOX BOT nodes, in one
zero-dependency C99 binary. It reads an explicit allowlist of local log files
and the local system journal, renders a responsive dark/light panel with
severity colouring and hit highlighting, and never writes anything or opens a
network socket.
┌──────────────────────── plugin_logs ────────────────────────┐
?action= │ sources list what can be read (journal / *.log / eventlog) │
JSON API │ tail last N entries of one source │
│ search case-insensitive substring search over one source │
│ units systemd units that have journal entries │
│ info plugin info, caps, auth state │
└─────────────────────────────────────────────────────────────┘
GET → HTML viewer (?embed=1 for the Chat floating window)
| Platform | Sources | |
|---|---|---|
| Linux | journalctl -o json (system journal and journal:<unit>); *.log directly under /var/log, plus syslog, messages, kern.log, auth.log; $HOME/.scorpiox/**/*.log and /workspace/**/*.log to depth 4 | |
| macOS | log show --style compact --last <Nm> (bounded to 60 min); *.log directly under /var/log, system.log; ~/Library/Logs/**/*.log to depth 3 | |
| Windows | `wevtutil qe System\ | Application /f:text (fixed argv); %LOCALAPPDATA%\scorpiox\*\.log` to depth 4 |
Nothing else is readable. A request for file:/etc/passwd, a directory, or an
id that is not in the current action=sources answer is refused with
source_not_allowed — the allowlist is the return value of the same walk the
UI is given, so there is no second path to a file.
Every walk has its own entry budget. /workspace being enormous cannot
consume the allowance that $HOME/.scorpiox needs, and action=sources
reports truncated: true instead of pretending the short list is complete.
Symlinks are never followed.
rb. Nothing is rotated, truncated or created.curl, no HTTP client, no listening socket. The plugin isa CGI-style executable; the node's server owns the socket.
journalctl and wevtutil are invoked, from fixed snprintf format strings. A systemd unit name must pass
[A-Za-z0-9@._-]{1,128} and may not start with -, so it can never become an
option or a shell word.
first partial line; searches stop after 8 000 lines and 500 hits.
make # native -> ./plugin_logs
make musl # static musl x86_64 (the universal Linux artifact)
make arm64 # static aarch64 (Pi 5 / ARM64 servers)
make win64 # static PE via MinGW-w64 -> plugin_logs.exe
make macos # Apple clang, run this on the Mac
make test # build + offline checks
On Windows, build.ps1 wraps the MinGW build and verifies the MZ header.
Copy the binary into the node's plugin dir and it is live immediately — no
server restart:
install -m 0755 plugin_logs ~/.scorpiox/plugins/plugin_logs
The plugin appears in the Plugins list and is served at /plugin_logs
(GET for the viewer, ?action=… for JSON). One-click install from the market
writes a plugin_logs.manifest.json sidecar with the source commit and the
artifact SHA-256.
All actions except --meta require the node password when BOT_PASSWORD is
set — X-Bot-Password, Authorization: Bearer <pwd>, or ?pwd= (what the
plugin iframe appends). With no BOT_PASSWORD the plugin is a deliberate no-op
so it can be run from a shell.
?action=sources
{ "ok":true, "journal_available":true, "count":5, "truncated":false,
"sources":[ {"id":"journal","label":"System journal","kind":"journal","size":0,"mtime":0},
{"id":"file:/var/log/dpkg.log","label":"dpkg.log","kind":"file",
"size":958818,"mtime":1773629060} ] }
?action=tail&src=journal&lines=200
{ "ok":true, "src":"journal", "count":2,
"entries":[ {"ts":"11-12 04:50:01","unit":"nginx.service","sev":"err",
"text":"upstream timed out"} ] }
?action=search&src=file:/var/log/dpkg.log&q=install
{ "ok":true, "scanned":8000, "count":500, "max":500, "truncated":true, "hits":[ … ] }
?action=units
{ "ok":true, "available":true, "count":3,
"units":[ {"name":"nginx.service","src":"journal:nginx.service"} ] }
sev is info, warn or err. On Linux it comes from the journal
PRIORITY field; everywhere it falls back to a keyword heuristic over the
message text (panic, fatal, error, failed, denied → err; warn,
deprecated, timeout, retry → warn).
<mark> highlighting of every hit.Reload to re-walk the source list.
err / warn. bot in a hub modal, a session card and the Chat floating window. ?theme=
decides before first paint; a {type:'sx-theme'} post from the host is
followed without a reload.
<script src=>, no CDN, no emoji (inline SVG only).
sh tests/run.sh # 153 offline assertions
python3 tests/e2e.py # Playwright: 1440/1024/390 × dark/light + behaviour
tests/run.sh replays a captured journalctl -o json stream and a fixture log
tree, so the parsers are tested against the real output layouts without needing
journald (or a growing log) on the build host:
SX_LOGS_JOURNAL_FIXTURE — a file replayed instead of running journalctl.SX_LOGS_EXTRA_ROOT — one extra allowlisted root, so fixtures live outsidethe production paths.
tests/e2e.py serves the plugin through a small CGI shim and asserts, at every
viewport and in both themes: no console error, no horizontal overflow, the
source picker is populated, a tail renders rows, severity classes are applied,
search highlights hits, follow pauses the poller, the line-count segment
switches, the theme button flips, and ?embed=1 drops only the back-link.
MIT. Copyright (c) 2026 SCORPIOX INC.