Skip to main content

Module request_log

Module request_log 

Source
Expand description

Append-only, local invocation + HTTP request log (log.jsonl).

Every omni-dev invocation appends one kind: "invocation" line; every outbound HTTP request made by one of the integration clients appends one kind: "http" line correlated to it by a shared invocation_id. The log is local-machine state written under the platform state/data directory (0700 dir / 0600 file, the same posture as crate::daemon::paths).

Design invariants:

  • Best effort. record swallows every error (logging only at tracing::debug); a logging failure can never change the program’s exit code. Honors OMNI_DEV_LOG_DISABLE=1 for an absolute opt-out.
  • No secrets. Auth headers/tokens are never written; only a non-secret auth_principal identity is kept. Headers are redacted centrally (redact_headers), secret-bearing URL query/fragment parameter values are redacted (redact_url) before writing, and request/response bodies are opt-in via OMNI_DEV_LOG_BODIES=1.
  • Forward compatible. A single LogRecord is used for both writing and reading: every field is #[serde(default)], and every optional field is skip_serializing_if, so a newer reader never chokes on an older line and an older reader never chokes on a newer one — the same forward-rolling contract the daemon wire types use.

Structs§

HttpExtra
Optional, non-secret extras for an HTTP record. Bodies/headers are gated and redacted centrally in record_http_with, so callers may pass them freely.
InvocationOutcome
The outcome of an invocation, recorded once after cli.execute() returns.
LogRecord
One line of the log. Used for both writing and reading; every field is #[serde(default)] (tolerant reads) and every optional field is skip_serializing_if (compact, forward-compatible writes).
PruneOptions
Options controlling prune.
PruneOutcome
What a prune run did (or, when dry_run, would do).
RequestLogContext
The per-invocation context every record is stamped with.

Enums§

RecordKind
Which kind of record a line holds. Unknown future kinds deserialize to RecordKind::Unknown rather than failing the read.
Source
What drove an invocation. Unknown future sources deserialize to Source::Unknown.

Statics§

CTX
Per-task context override, set around each MCP tool dispatch.

Functions§

bodies_enabled
Whether request/response bodies may be recorded (OMNI_DEV_LOG_BODIES=1).
current_context
Resolves the active context: task-local override first, then the process-global default, then a synthesized fallback.
disabled
Whether logging is disabled entirely (OMNI_DEV_LOG_DISABLE=1).
headers_enabled
Whether (redacted) headers may be recorded (OMNI_DEV_LOG_HEADERS=1).
log_file_path
Resolves the log file path: OMNI_DEV_LOG_FILE override, else state_dir (falling back to data_dir) joined with omni-dev/log.jsonl.
new_id
A time-sortable id: 13-digit zero-padded epoch-millis, a dash, then 16 hex.
prune
Prunes the log at path by age and/or size, rewriting it in place.
record
Appends one record. Best effort: every error is swallowed (logged at tracing::debug) so logging can never affect the caller’s exit code.
record_http
Appends one kind: "http" record with method/url/status/elapsed/error.
record_http_result
Appends one kind: "http" record from a reqwest send result, mapping Ok → status code and Err → error message.
record_http_with
Appends one kind: "http" record with extra, non-secret fields.
record_invocation
Appends one kind: "invocation" record from the active context.
redact_headers
Replaces sensitive header values with REDACTED, passing others through.
set_global
Installs the process-global context. The first call wins (the CLI/daemon shell sets it once, very early); later calls are ignored.