sc_observability/
jsonl_reader.rs1#![expect(
2 clippy::missing_errors_doc,
3 reason = "reader error behavior is documented at the public facade level, and repeating it here would add low-signal boilerplate"
4)]
5#![expect(
6 clippy::must_use_candidate,
7 reason = "lightweight constructors are intentionally kept free of repetitive must_use decoration"
8)]
9
10use std::path::PathBuf;
11use std::sync::Arc;
12
13use sc_observability_types::{LogQuery, LogSnapshot, QueryError, QueryHealthState};
14
15use crate::follow::LogFollowSession;
16use crate::health::QueryHealthTracker;
17use crate::query;
18
19#[derive(Debug, Clone)]
21pub struct JsonlLogReader {
22 active_log_path: PathBuf,
23}
24
25impl JsonlLogReader {
26 pub fn new(active_log_path: PathBuf) -> Self {
28 Self { active_log_path }
29 }
30
31 pub fn query(&self, query: &LogQuery) -> Result<LogSnapshot, QueryError> {
33 query::query_snapshot(&self.active_log_path, query)
34 }
35
36 pub fn follow(&self, query: LogQuery) -> Result<LogFollowSession, QueryError> {
38 LogFollowSession::with_health(
39 self.active_log_path.clone(),
40 query,
41 Arc::new(QueryHealthTracker::new(QueryHealthState::Healthy)),
42 None,
43 )
44 }
45}