pub trait LogStore: Send + Sync {
// Required methods
fn append(&self, daemon_id: &DaemonId, message: &str) -> Result<()>;
fn query(&self, opts: &LogQuery) -> Result<Vec<LogEntry>>;
fn tail(
&self,
daemon_id: &DaemonId,
after_id: Option<i64>,
) -> Result<Vec<LogEntry>>;
fn clear(&self, daemon_ids: &[DaemonId]) -> Result<()>;
fn list_daemon_ids(&self) -> Result<Vec<String>>;
// Provided methods
fn append_structured(
&self,
daemon_id: &DaemonId,
parsed: &ParsedLog,
) -> Result<()> { ... }
fn append_structured_batch(
&self,
daemon_id: &DaemonId,
entries: &[ParsedLog],
) -> Result<()> { ... }
fn append_batch(
&self,
daemon_id: &DaemonId,
messages: &[String],
) -> Result<()> { ... }
fn apply_retention(
&self,
policy: &RetentionPolicy,
excluded_daemon_ids: &[DaemonId],
archive_hook: Option<&ArchiveHook>,
) -> Result<u64> { ... }
fn apply_retention_for_daemon(
&self,
daemon_id: &DaemonId,
policy: &RetentionPolicy,
archive_hook: Option<&ArchiveHook>,
) -> Result<u64> { ... }
fn last_id(&self, daemon_id: &DaemonId) -> Result<Option<i64>> { ... }
fn last_clear_generation(&self, daemon_id: &DaemonId) -> Result<Option<u64>> { ... }
}Expand description
Unified interface for log storage and retrieval.
Required Methods§
Sourcefn append(&self, daemon_id: &DaemonId, message: &str) -> Result<()>
fn append(&self, daemon_id: &DaemonId, message: &str) -> Result<()>
Append a single log line (unstructured).
Sourcefn query(&self, opts: &LogQuery) -> Result<Vec<LogEntry>>
fn query(&self, opts: &LogQuery) -> Result<Vec<LogEntry>>
Query logs according to the given options.
Sourcefn tail(
&self,
daemon_id: &DaemonId,
after_id: Option<i64>,
) -> Result<Vec<LogEntry>>
fn tail( &self, daemon_id: &DaemonId, after_id: Option<i64>, ) -> Result<Vec<LogEntry>>
Read new log entries for a daemon.
When after_id is Some(id), returns only entries with row id > id.
When after_id is None, returns all entries for the daemon.
Sourcefn list_daemon_ids(&self) -> Result<Vec<String>>
fn list_daemon_ids(&self) -> Result<Vec<String>>
List all daemon IDs that have log entries.
Provided Methods§
Sourcefn append_structured(
&self,
daemon_id: &DaemonId,
parsed: &ParsedLog,
) -> Result<()>
fn append_structured( &self, daemon_id: &DaemonId, parsed: &ParsedLog, ) -> Result<()>
Append a single parsed log line with structured fields.
The default implementation discards structured fields and falls back
to append.
Sourcefn append_structured_batch(
&self,
daemon_id: &DaemonId,
entries: &[ParsedLog],
) -> Result<()>
fn append_structured_batch( &self, daemon_id: &DaemonId, entries: &[ParsedLog], ) -> Result<()>
Append multiple parsed log lines in a single transaction.
The default implementation calls append_structured for each line.
Sourcefn append_batch(&self, daemon_id: &DaemonId, messages: &[String]) -> Result<()>
fn append_batch(&self, daemon_id: &DaemonId, messages: &[String]) -> Result<()>
Append multiple log lines in a single transaction.
The default implementation falls back to calling append for each line.
Sourcefn apply_retention(
&self,
policy: &RetentionPolicy,
excluded_daemon_ids: &[DaemonId],
archive_hook: Option<&ArchiveHook>,
) -> Result<u64>
fn apply_retention( &self, policy: &RetentionPolicy, excluded_daemon_ids: &[DaemonId], archive_hook: Option<&ArchiveHook>, ) -> Result<u64>
Apply a retention policy (age-based and/or count-based pruning).
By default this applies to all daemons; excluded_daemon_ids can be
used to skip daemons that have their own per-daemon overrides, so the
global policy does not accidentally prune entries those daemons intend
to keep.
Sourcefn apply_retention_for_daemon(
&self,
daemon_id: &DaemonId,
policy: &RetentionPolicy,
archive_hook: Option<&ArchiveHook>,
) -> Result<u64>
fn apply_retention_for_daemon( &self, daemon_id: &DaemonId, policy: &RetentionPolicy, archive_hook: Option<&ArchiveHook>, ) -> Result<u64>
Apply a retention policy to a specific daemon’s logs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".