#![expect(
clippy::missing_errors_doc,
reason = "reader error behavior is documented at the public facade level, and repeating it here would add low-signal boilerplate"
)]
#![expect(
clippy::must_use_candidate,
reason = "lightweight constructors are intentionally kept free of repetitive must_use decoration"
)]
use std::path::PathBuf;
use std::sync::Arc;
use sc_observability_types::{LogQuery, LogSnapshot, QueryError, QueryHealthState};
use crate::follow::LogFollowSession;
use crate::health::QueryHealthTracker;
use crate::query;
#[derive(Debug, Clone)]
pub struct JsonlLogReader {
active_log_path: PathBuf,
}
impl JsonlLogReader {
pub fn new(active_log_path: PathBuf) -> Self {
Self { active_log_path }
}
pub fn query(&self, query: &LogQuery) -> Result<LogSnapshot, QueryError> {
query::query_snapshot(&self.active_log_path, query)
}
pub fn follow(&self, query: LogQuery) -> Result<LogFollowSession, QueryError> {
LogFollowSession::with_health(
self.active_log_path.clone(),
query,
Arc::new(QueryHealthTracker::new(QueryHealthState::Healthy)),
None,
)
}
}