use crate::record::LogRecord;
use std::fmt::Debug;
#[derive(Debug, thiserror::Error)]
pub enum ScoutyError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Parse error: {0}")]
Parse(String),
#[error("Config error: {0}")]
Config(String),
#[error("Filter error: {0}")]
Filter(String),
#[error("Other: {0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, ScoutyError>;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LoaderType {
TextFile,
Archive,
Syslog,
Otlp,
}
#[derive(Debug, Clone)]
pub struct LoaderInfo {
pub id: String,
pub loader_type: LoaderType,
pub multiline_enabled: bool,
pub sample_lines: Vec<String>,
pub file_mod_year: Option<i32>,
}
pub trait LogLoader: Debug + Send {
fn info(&self) -> &LoaderInfo;
fn load(&mut self) -> Result<Vec<String>>;
}
pub trait LogParser: Debug + Send {
fn parse(&self, raw: &str, source: &str, loader_id: &str, id: u64) -> Option<LogRecord>;
fn name(&self) -> &str;
}
pub trait LogFilter: Debug + Send {
fn matches(&self, record: &LogRecord) -> bool;
fn description(&self) -> &str;
}
pub trait LogProcessor: Debug + Send {
fn process(&self, records: &[LogRecord]) -> Result<()>;
fn name(&self) -> &str;
}
pub trait LogAnalyzer: Debug + Send {
fn analyze(&self, records: &[LogRecord]) -> Result<String>;
fn name(&self) -> &str;
}