pub struct DiagnosticsCollector { /* private fields */ }Expand description
Central coordinator for diagnostic logging.
Checks RALPH_DIAGNOSTICS environment variable and creates a timestamped
session directory if enabled.
Implementations§
Source§impl DiagnosticsCollector
impl DiagnosticsCollector
Sourcepub fn new(base_path: &Path) -> Result<Self>
pub fn new(base_path: &Path) -> Result<Self>
Creates a new diagnostics collector.
If RALPH_DIAGNOSTICS=1, creates .ralph/diagnostics/<timestamp>/ directory.
Sourcepub fn with_enabled(base_path: &Path, enabled: bool) -> Result<Self>
pub fn with_enabled(base_path: &Path, enabled: bool) -> Result<Self>
Creates a diagnostics collector with explicit enabled flag (for testing).
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
Creates a disabled diagnostics collector without any I/O (for testing).
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns whether diagnostics are enabled.
Sourcepub fn session_dir(&self) -> Option<&Path>
pub fn session_dir(&self) -> Option<&Path>
Returns the session directory if diagnostics are enabled.
Sourcepub fn wrap_stream_handler<H>(
&self,
handler: H,
) -> Result<DiagnosticStreamHandler<H>, H>
pub fn wrap_stream_handler<H>( &self, handler: H, ) -> Result<DiagnosticStreamHandler<H>, H>
Wraps a stream handler with diagnostic logging.
Returns the original handler if diagnostics are disabled.
Sourcepub fn log_orchestration(
&self,
iteration: u32,
hat: &str,
event: OrchestrationEvent,
)
pub fn log_orchestration( &self, iteration: u32, hat: &str, event: OrchestrationEvent, )
Logs an orchestration event.
Does nothing if diagnostics are disabled.
Sourcepub fn log_performance(
&self,
iteration: u32,
hat: &str,
metric: PerformanceMetric,
)
pub fn log_performance( &self, iteration: u32, hat: &str, metric: PerformanceMetric, )
Logs a performance metric.
Does nothing if diagnostics are disabled.
Sourcepub fn log_error(&self, iteration: u32, hat: &str, error: DiagnosticError)
pub fn log_error(&self, iteration: u32, hat: &str, error: DiagnosticError)
Logs an error.
Does nothing if diagnostics are disabled.