pub struct Logger { /* private fields */ }Implementations§
Source§impl Logger
impl Logger
pub fn new(config: LogConfig) -> Self
pub fn with_otel_exporter( config: LogConfig, otel_config: OtelConfig, exporter: Arc<dyn OtelExporter>, ) -> Self
pub fn config(&self) -> &LogConfig
Sourcepub fn emit(&self, event: &LogEventV1) -> Result<(), LoggerError>
pub fn emit(&self, event: &LogEventV1) -> Result<(), LoggerError>
Validate, redact, and append an event to the canonical JSONL log.
§Errors
Returns an error when validation fails, serialization fails, the event
exceeds max_event_bytes, or filesystem writes fail.
Sourcepub fn emit_action(
&self,
source_binary: &str,
target: &str,
action: &str,
outcome: Option<&str>,
fields: Value,
) -> Result<(), LoggerError>
pub fn emit_action( &self, source_binary: &str, target: &str, action: &str, outcome: Option<&str>, fields: Value, ) -> Result<(), LoggerError>
Convenience helper for tools that only need action/outcome + fields.
This builds a LogEventV1 with the configured log level and emits it
through the same validation/redaction/path pipeline as Self::emit.
Sourcepub fn emit_human(
&self,
level: &str,
action: &str,
outcome: &str,
fields: &Value,
) -> Result<(), LoggerError>
pub fn emit_human( &self, level: &str, action: &str, outcome: &str, fields: &Value, ) -> Result<(), LoggerError>
Write a human-readable log line to the canonical log path.
Produces <timestamp> level=<level> action=<action> outcome=<outcome> fields=<json>
format, sharing the same file-path and directory-creation logic as
Self::emit. This routes Human-mode output through SharedLogger rather
than a parallel per-tool implementation.
§Errors
Returns an error when directory creation or file appending fails.
Sourcepub fn write_to_spool(
&self,
event: &LogEventV1,
unix_millis: u128,
) -> Result<PathBuf, LoggerError>
pub fn write_to_spool( &self, event: &LogEventV1, unix_millis: u128, ) -> Result<PathBuf, LoggerError>
Write one event to a per-source spool file for deferred fan-in merge.
§Errors
Returns an error when validation/serialization fails, the event exceeds
max_event_bytes, or spool file creation/appending fails.
Sourcepub fn merge_spool(&self) -> Result<u64, LoggerError>
pub fn merge_spool(&self) -> Result<u64, LoggerError>
Merge spool fragments into the canonical log in deterministic order.
Supports crash-recovery of stale .claiming files from interrupted
prior merges.
§Errors
Returns an error when reading the spool directory or writing to the canonical log fails.