- Added `RpcError` enum for comprehensive error handling in RPC operations. - Introduced `HealthReporter` and `HealthService` for managing service health statuses. - Implemented health check and watch functionality in the health service. - Created integration tests for health check service, covering various scenarios. - Added unit tests for client options validation and stream functionality. - Established logging infrastructure for terminal and registry components. - Implemented logging lifecycle management and conflict resolution in tests.
FlySim Log
flysim-log is the shared logging infrastructure crate in the log/ workspace
directory. Import it as flysim_log; keep using the third-party log crate's
log::info!, warn! and error! macros for business records.
It has no dependency on proto, Registry or Terminal, reads no environment
variables, and performs no initialization merely by being linked.
API And Ownership
use flysim_log::{LoggingConfig, build_subscriber, install_log_bridge, install_subscriber, parse_level};
fn initialize() -> Result<flysim_log::LoggingGuard, flysim_log::LoggingError> {
let config = LoggingConfig {
level: parse_level("info")?,
directory: "logs/my-service".into(),
file_prefix: "my-service".into(),
max_files: 10,
};
let (subscriber, guard) = build_subscriber(&config)?;
install_log_bridge()?;
install_subscriber(subscriber)?;
Ok(guard)
}
Keep the returned guard alive until all producers have stopped and the final
record has been emitted. Dropping it drains the file worker during normal exit;
it does not uninstall global logging. Do not use process::exit to bypass it.
LoggingConfigselects level, directory, filename prefix and retention count. Levels areoff/error/warn/info/debug/trace(case-insensitive when parsed). The directory/prefix must be nonempty, the count positive, and the prefix a portable single filename component rather than a path.build_subscriberconstructs atracing::DispatchandLoggingGuardwithout installing globals.build_with_writerpermits an injected console writer for scoped tests or embedding.install_log_bridgeinstallstracing-log::LogTracerforlogrecords;install_subscriberinstalls the prepared tracing subscriber. Native tracing fields and spans are supported as well. Do not also initializeenv_logger.stderr_subscriberconstructs a temporary console-only dispatcher. Registry uses it after bridge installation to report failures before file logging is ready. The caller supplies the contextual message and exit policy.LoggingErrordistinguishes invalid configuration, appender failure and already-installed globals, preserving backend error sources. Components map these errors into their own public/FFI error models.
The two global installations are not an atomic operation and cannot be rolled back. Serialize initialization with other host logging setup. A failed second installation can leave the first global installed; drop the new guard on failure, report the conflict, and never silently replace an existing logger/subscriber.
Output Contract
Each record is written to stderr and a daily UTC file named
<prefix>.YYYY-MM-DD.log. Both include timestamp, level and target; files never
contain ANSI codes. The default console writer detects terminal color support.
The chosen level filters both outputs.
Retention removes old matching prefix/suffix files at initialization or rotation.
max_files is an upper bound, not an exact count or a number of days. Use a
dedicated directory per process. Daily rotation does not limit individual file
size and is driven by arriving records rather than an idle timer.
File output uses an 8192-entry bounded queue with lossy(false). Full queues
block producers; stderr is synchronous. Slow output can delay RPC or host
threads. Guard cleanup is not a durability guarantee against forced exit, disk
failure, a stalled writer or power loss.
Registry retains the guard in its process entry point. Terminal retains it in its FFI lifecycle state until explicit logging shutdown. Extracting this crate does not make independently linked DLLs share Rust globals; keep a DLL that installed global logging loaded until host process exit.
Tests
Tests live under tests/unit and are loaded by the library's test-only
entry. They cover configuration, filtering, retention, append/flush and queue
backpressure. Registry keeps the end-to-end log bridge/dual-output test;
Terminal keeps isolated initialization-conflict and real DLL ABI tests.
cargo test -p flysim-log
cargo test -p registry -p terminal logging