Skip to main content

Crate smix_metro_log

Crate smix_metro_log 

Source
Expand description

smix-metro-log — metro / expo log tail + ring buffer + signal await.

§Purpose

Bridges the app-under-test’s log output into smix as a first-class signal channel. yaml flows can expect.signal { regex, timeoutMs } or expect.signals { [{regex}, ...], order: strict } to assert on state transitions the app declares — decoupling smix from what the UI looks like at any instant.

§Architecture

  ┌─────────────────┐     WebSocket           ┌────────────────┐
  │ metro / expo    │  ─────────────────▶      │ MetroLogTail   │
  │ dev server      │     (or file tail)       │  ring buffer   │
  │ ws://127.0.0.1  │                          │  + allowlist   │
  │  :8081/logs     │                          └────────┬───────┘
  └─────────────────┘                                   │
                                                        │ await_signal
                                                        │ await_signals
                                                        │ assert_clean
                                                        ▼
                                             ┌────────────────────┐
                                             │ smix-adapter-      │
                                             │  maestro runtime   │
                                             │ (expect.signal /   │
                                             │  expect.signals)   │
                                             └────────────────────┘

§Time model

  • Ring buffer — stores the last retain_secs seconds of entries (default 300s). Entries older than the cutoff are evicted on push.

  • Windows — await_signal accepts a Window:

    • SinceStep(usize) — logically “everything after step N ended”
    • SinceRun — since MetroLogTail was constructed (runner boot)
    • LastMs(u64) — trailing window (e.g. last 500 ms)

    The adapter runtime tracks step boundaries and translates SinceStep to an absolute timestamp captured at step-end.

  • Poll frequency — await_signal runs a scan loop at 25 ms intervals. Publishes into the ring buffer are unbounded (async channel + mutex-protected buffer) so the poll never misses.

Re-exports§

pub use process::ProcessSubscriber;
pub use subscriber::FileTailSubscriber;
pub use subscriber::SubscriberHandle;
pub use subscriber::WebSocketSubscriber;
pub use subscriber::parse_log_line;

Modules§

process
A log source that is a running program: each line it prints is an entry.
subscriber
Log source subscribers.

Structs§

LogEntry
Metro / expo log entry, normalized. Level is best-effort: metro text-only lines get LogLevel::Log; JSON-formatted lines keep their level if parseable.
MetroLogTail
Ring-buffer + await surface for metro/expo logs.
SignalMatcher
Compiled signal pattern.

Enums§

AwaitError
LogLevel
SignalOrder
Order semantics for MetroLogTail::await_signals.
Window
Window over which to look for a matching signal.