Skip to main content

Crate truefix_log

Crate truefix_log 

Source
Expand description

truefix-log — pluggable FIX logging with message/event stream separation (FR-H2).

The Log trait separates message logging (inbound/outbound wire messages) from event logging (session lifecycle, errors). Implementations: ScreenLog, FileLog, TracingLog, and CompositeLog (fan-out).

Audit 006 additions: FileLogOptions::max_size_bytes rotates messages.log/event.log once either exceeds the configured size (NEW-108); FileLog always timestamps event lines and surfaces write failures instead of discarding them silently (NEW-124, NEW-125); and LogConfig (in truefix-config) threads file-backend options through generic log configuration (NEW-126).

Feature 012 (audit 007) additions: FileLog’s constructors (open/open_with_options, and build_log for LogConfig::File) are now async and queue writes onto a bounded channel consumed by a background writer task — the same channel + background-writer shape SqlLog/MssqlLog/MongoLog/RedbLog (each behind its own Cargo feature) already use — so on_incoming/on_outgoing/on_event never block the calling async task on disk I/O (NEW-156). Log::shutdown on FileLog drains that queue before returning; a background write/flush failure is surfaced via a structured tracing::error! event and a truefix_log_write_failures_total metrics counter (NEW-156, FR-009) instead of the previous best-effort eprintln!.

Design: specs/001-fix-engine-parity/, specs/012-audit-007-remediation/.

Structs§

CompositeLog
Fans every entry out to each wrapped log.
FileLog
Logs inbound/outbound messages to messages.log and events to event.log via a bounded channel and background writer task (NEW-156).
FileLogOptions
Output switches for FileLog (FR-026): FileLogHeartbeats/FileIncludeMilliseconds/ FileIncludeTimeStampForMessages.
RetentionPolicy
Composable retention policy for FileLog’s rotated backups (NEW-157). Both fields are independently optional and may be set together (e.g. “roll daily, keep the last 30 dated files”).
ScreenLog
Logs messages to stdout and events to stderr, with direction prefixes.
ScreenLogOptions
Output switches for ScreenLog (FR-026): ScreenLogShowEvents/ScreenLogShowHeartBeats/ ScreenLogShowIncoming/ScreenLogShowOutgoing/ScreenIncludeMilliseconds.
SessionPrefixLog
Wraps any Log implementation, prepending [{session_id}] to every message/event before delegating. Generic over the wrapped log so it composes with any sink (screen/file/SQL/ tracing/composite) without each implementation needing its own session-ID-prefix option.
TracingLog
Logs via the tracing facade, separating message and event targets.
TracingLogOptions
Output switches for TracingLog (FR-026): SLF4JLogHeartbeats. Session-ID prefixing (SLF4JLogPrependSessionID) is provided generically by wrapping in crate::SessionPrefixLog rather than as a field here.

Enums§

LogConfig
Which log backend to construct.
LogError
An error constructing a log.

Traits§

Log
A FIX log sink. Message logging (incoming/outgoing) is kept separate from event logging.

Functions§

build_log
Build a boxed Log from a LogConfig.