Logging Parse
OpenFrame Documentation
Get the most out of OpenFrame · Book 30 minutes with Conrad, 25 years in IT. He'll show you what Mingo and Fae can take off your list.
OpenFrame Documentation
Logging Parse is the OpenFrame Client component that converts incremental records from the client log file into structured log entries. It recognizes the client tracing format and a tool-oriented log format, limits each read to a requested number of parsed entries, and can compact repeated tool messages before a batch is sent onward.
The implementation is supplied by the openframe_agent_lib Rust artifact from OpenFrame OSS Library version 0.0.5. The tenant repository runs it as part of its OpenFrame Client workload. The authoritative implementation is log_parser.rs.
LogEntry values while ignoring unreadable and unsupported lines.Logging Parse does not write logs, persist offsets, rotate files, publish a batch, or configure the logging subscriber. Those concerns belong to the neighboring logging capabilities in the client runtime.
flowchart LR
Runtime["OpenFrame Client Runtime"] --> Writer["Client and Tool Log File"]
Writer --> Reader["Logging Parse"]
Reader --> Parser["Line Format Parser"]
Parser --> Entries["Structured Log Entries"]
Entries --> Dedup["Tool Message Deduplicator"]
Dedup --> Batch["Log Batch Message"]
Batch --> Downstream["Shipping or Streaming Runtime"]
The parser is deliberately file-oriented: callers provide the log-file path, a previously known byte position, and a maximum entry count. The returned position is intended to become the next checkpoint, while the caller controls checkpoint storage and delivery semantics.
| Type | Purpose | Serialized behavior |
|---|---|---|
LogEntry |
One normalized log record. | Contains level, ts, and msg. The optional count field is omitted until deduplication observes a repeat. |
LogBatchMessage |
A device-scoped group of log entries. | Uses camel-case property names. machineId and organizationId are omitted when absent; hostname, tenantDomain, and logs are always present. |
LogDeduplicator |
Extension trait implemented for Vec<LogEntry>. |
Consumes the vector and returns the filtered, ordered vector. |
LogEntry.ts remains a string rather than a parsed time object. Timestamp validation is used only while recognizing tracing-format input, preserving the accepted textual timestamp for the output record.
Logging Parse tries the tracing format first, then the tool format. A line that matches neither format produces no entry.
flowchart TD
Start["Read one line"] --> Trace{"Valid tracing format?"}
Trace -->|"yes"| TraceEntry["Create client log entry"]
Trace -->|"no"| Normalize["Remove optional stdout prefix"]
Normalize --> Tool{"Tool fields present?"}
Tool -->|"yes"| ToolEntry["Create tool log entry"]
Tool -->|"no"| Skip["Ignore line"]
TraceEntry --> Next["Continue reading"]
ToolEntry --> Next
Skip --> Next
A tracing record must begin with an RFC 3339 timestamp ending at the first Z. The prefix through that Z is validated using Chrono. After whitespace, the first token is the level and all remaining text is the message.
2026-03-01T12:00:00Z INFO openframe client started
This produces a LogEntry with timestamp 2026-03-01T12:00:00Z, level INFO, and message openframe client started.
For the fallback format, an optional leading stdout: is removed and leading whitespace is trimmed. The remaining line must start with time=", include a whitespace-terminated level= value, and include msg=". The parser converts the level to uppercase and prefixes the extracted message with [tool] .
stdout: time="2026-03-01T12:00:00Z" level=warning msg="service restarted"
This produces a timestamp of 2026-03-01T12:00:00Z, level WARNING, and message [tool] service restarted.
The tool parser does not parse quoted-field escaping or validate the timestamp. It extracts fields using the expected textual layout. The message is the text following msg=" with trailing quote characters removed.
read_new_logs implements a stateless read operation around a caller-supplied position:
sequenceDiagram
participant Caller
participant Parser as Logging Parse
participant File as Log File
Caller->>Parser: read path, position, maximum count
Parser->>File: open and read metadata
alt file length is below position
Parser->>Parser: use position zero
else file has retained position
Parser->>Parser: use supplied position
end
Parser->>File: seek and read lines
Parser->>Parser: parse supported lines
Parser-->>Caller: entries and new position
Important operational details:
Deduplication is an explicit, consuming operation on a Vec<LogEntry>; parsing alone does not merge anything.
flowchart TD
Input["Parsed Log Entry"] --> Client{"Preserve as client log?"}
Client -->|"yes"| Keep["Append unchanged"]
Client -->|"no"| Seen{"Message seen before?"}
Seen -->|"no"| First["Store first entry index and append"]
Seen -->|"yes"| Count["Increment retained entry count"]
Keep --> Output["Ordered Deduplicated Entries"]
First --> Output
Count --> Output
An entry is preserved without deduplication when its level is TOOL, or when its message starts with openframe or async_nats. Every other entry is treated as a tool entry for this purpose. Repeated entries are identified solely by exact msg equality:
count changes from absent to 2 on the second occurrence and increases for each later occurrence.This means a non-client message with the same text but a different timestamp or level will be folded into the first occurrence. Changes to the message normalization rules therefore change the aggregation boundary and should be considered protocol-affecting for downstream log consumers.
flowchart TD
Config["Logging Configuration"] --> Setup["Logging Setup"]
Setup --> File["Active Client Log File"]
File --> Parse["Logging Parse"]
Parse --> Rotation["Rotation and Offset Management"]
Parse --> Shipping["Log Shipping"]
Parse --> Streaming["NATS Log Streaming"]
Shipping --> Receiver["Platform Log Ingestion"]
Streaming --> Receiver
The runtime surrounding Logging Parse selects the log-file location, schedules reads, saves or restores offsets, and chooses a transport. The batch envelope supplies tenancy and machine context required by the receiving platform, while LogEntry provides the normalized log payload.
Keep the tracing parser ahead of fallback parsers so an unambiguous client record remains client-originated. Add a focused parser that returns None for non-matches rather than treating arbitrary input as a valid event. Decide whether the new format must retain its own source marker, as the tool parser does with [tool] .
Preserve the truncation check and test reads at the beginning of a file, at a saved position, after truncation, and at the maximum-entry boundary. Offset persistence and file rotation are external to this module, so compatibility depends on the contract between this return value and those callers.
Test client logs, NATS logs, explicit TOOL logs, first occurrences, repeated messages, and messages with identical text but differing timestamps or levels. If deduplication begins using more than the message text, update consumers that interpret count as repeated identical output.
stdout: prefix.