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 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§

Source

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

Append a single log line (unstructured).

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 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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn last_id(&self, daemon_id: &DaemonId) -> Result<Option<i64>>

Return the highest row id for the given daemon, or None if no entries exist. Used by tailing loops to advance the cursor past non-matching rows without re-scanning them on every poll.

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§