pub struct RunTraceWriter { /* private fields */ }Expand description
Run-specific trace writer
Generates trace files for run command failures with run-specific context and metadata.
§Example
use std::path::PathBuf;
use std::sync::Arc;
use torrust_tracker_deployer_lib::infrastructure::trace::RunTraceWriter;
use torrust_tracker_deployer_lib::shared::SystemClock;
let traces_dir = PathBuf::from("data/my-env/traces");
let clock = Arc::new(SystemClock);
let writer = RunTraceWriter::new(traces_dir, clock);Implementations§
Source§impl RunTraceWriter
impl RunTraceWriter
Sourcepub fn new(traces_dir: impl Into<PathBuf>, clock: Arc<dyn Clock>) -> Self
pub fn new(traces_dir: impl Into<PathBuf>, clock: Arc<dyn Clock>) -> Self
Create a new run trace writer
Sourcepub fn write_trace<E: Traceable>(
&self,
ctx: &RunFailureContext,
error: &E,
) -> Result<PathBuf, TraceWriterError>
pub fn write_trace<E: Traceable>( &self, ctx: &RunFailureContext, error: &E, ) -> Result<PathBuf, TraceWriterError>
Write a run failure trace file
Generates a trace file with run-specific context and logs the outcome. Success is logged at INFO level, failures at WARN level.
§Arguments
ctx- The run failure context with metadataerror- The error that implementsTraceablefor chain extraction
§Returns
Path to the generated trace file
§Errors
Returns an error if directory creation or file writing fails
Sourcepub fn traces_dir(&self) -> &Path
pub fn traces_dir(&self) -> &Path
Get the traces directory path
Auto Trait Implementations§
impl !RefUnwindSafe for RunTraceWriter
impl !UnwindSafe for RunTraceWriter
impl Freeze for RunTraceWriter
impl Send for RunTraceWriter
impl Sync for RunTraceWriter
impl Unpin for RunTraceWriter
impl UnsafeUnpin for RunTraceWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request