Skip to main content

LogStore

Trait LogStore 

Source
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 apply_retention(
        &self,
        policy: &RetentionPolicy,
        excluded_daemon_ids: &[DaemonId],
    ) -> Result<u64> { ... }
    fn apply_retention_for_daemon(
        &self,
        daemon_id: &DaemonId,
        policy: &RetentionPolicy,
    ) -> Result<u64> { ... }
    fn last_clear_generation(&self, daemon_id: &DaemonId) -> Result<Option<u64>> { ... }
}
Expand description

Unified interface for log storage and retrieval.

Required Methods§

Source

fn append(&self, daemon_id: &DaemonId, message: &str) -> Result<()>

Append a single log line.

Source

fn query(&self, opts: &LogQuery) -> Result<Vec<LogEntry>>

Query logs according to the given options.

Source

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.

Source

fn clear(&self, daemon_ids: &[DaemonId]) -> Result<()>

Clear all logs for the given daemon(s).

Source

fn list_daemon_ids(&self) -> Result<Vec<String>>

List all daemon IDs that have log entries.

Provided Methods§

Source

fn apply_retention( &self, policy: &RetentionPolicy, excluded_daemon_ids: &[DaemonId], ) -> 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.

Source

fn apply_retention_for_daemon( &self, daemon_id: &DaemonId, policy: &RetentionPolicy, ) -> Result<u64>

Apply a retention policy to a specific daemon’s logs.

Source

fn last_clear_generation(&self, daemon_id: &DaemonId) -> Result<Option<u64>>

Return the generation number for the daemon’s last clear operation. Each call to clear bumps the generation, so SSE streams can detect when logs have been wiped and refresh their display.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§