You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(daemon): log startup, socket, driver, and connection lifecycle
daemon.log has been an empty crash dump since the daemon's only write to
either stream was a fatal console.error(). There was no startup line, no
shutdown line, and no record of socket claim/recovery or driver discovery, so
a misbehaving long-lived daemon left no trace to read back.
Adds a Logger port (JsonLinesLogger over an injected LogSink, with
module-scoped child()) alongside the existing Filesystem/Clock/DaemonLauncher
ports. Production logging goes through NodeFileLogSink, which owns an append
handle on ~/.pitlane/daemon.log, tracks bytes written, and rotates to
daemon.log.1 (replacing any previous generation) once config.log.rotateBytes
is exceeded -- keeping exactly one rotated generation so growth is bounded.
Tests use MemoryLogSink and assert parsed records, not string fragments.
startDaemon builds the logger from config.log.level right after config loads
and hands scoped children to DaemonEndpointHost, DaemonServer, and driver
discovery, covering: daemon start (version, protocol version, socket path,
effective config), socket claim and stale-endpoint recovery, driver discovery
results including the Android SDK-missing skip, connection open/close with
declared capabilities, clean shutdown, and unexpected vs. handled request
errors (INTERNAL logs at error level, everything else at debug).
The fatal top-level handler in main.ts can't depend on config.log -- config
loading is exactly what may have failed -- so it builds its own logger
straight from the default log path at a fixed level, falling back to
console.error only if that itself throws.
Because NodeDaemonLauncher hands the child an inherited append fd on the same
path for uncaught fatal output, a crash stack can still land in the rotated
file. pitlane daemon logs now reads daemon.log.1 followed by daemon.log so a
crash right before rotation is never silently lost.
Config gained a log section (level, default "info"; rotateBytes, default
5 MiB), validated like its neighbors and readable via `pitlane config get
log`.
0 commit comments