Skip to main content

Module hostlog

Module hostlog 

Source
Expand description

Shared request/response log. Chrome spawns a SEPARATE native-messaging host process per sendNativeMessage (and one per persistent connectNative port), so no single process sees every command. To let the HUD “HOST” tab show ALL tx/rx to zwire-host regardless of which client/process handled it, every process appends a compact JSON line to one shared ring-capped file (~/.zwire/hostlog.jsonl). The HOST tab reads it back via the hostlog command. Streaming frames (sysinfo/pty/job output) are pushed with out.send directly rather than respond, so only real commands + their replies land here — not the high-frequency stream noise.

Functions§

read_tail
Return the newest n entries (oldest→newest) for the HOST tab.
record
Append one tx/rx entry to the shared log. dir is “tx” (request) or “rx” (response). req is always the originating request (for the cmd + id); data is what to summarise (the request for tx, the response for rx).