pub struct TraceWriter { /* private fields */ }Expand description
Buffered, flush-on-drop trace writer.
Events accumulate in memory; flush (called on drop, or explicitly)
writes the buffered JSON array to disk. Disabled via the special
“no-op” constructor for builds where FERRUM_TRACE_OUT is unset —
push becomes a no-op so probe call-sites can call into the writer
unconditionally.
Implementations§
Source§impl TraceWriter
impl TraceWriter
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Construct from env var FERRUM_TRACE_OUT. If unset or empty,
returns a disabled writer whose push is a no-op.
pub fn from_env_vars<I, K, V>(vars: I) -> Self
pub fn enabled(out_path: PathBuf) -> Self
pub fn disabled() -> Self
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
True if the writer is configured to emit. Probes can use this to
skip the BackendTimer overhead entirely when tracing is off.
Sourcepub fn push(
&self,
name: impl Into<String>,
cat: impl Into<String>,
dur_ms: f64,
tid: u32,
)
pub fn push( &self, name: impl Into<String>, cat: impl Into<String>, dur_ms: f64, tid: u32, )
Record a complete event with name, cat, elapsed milliseconds.
tid should identify the layer / sub-op (0 for top-level engine).
Trait Implementations§
Source§impl Drop for TraceWriter
impl Drop for TraceWriter
Auto Trait Implementations§
impl !Freeze for TraceWriter
impl RefUnwindSafe for TraceWriter
impl Send for TraceWriter
impl Sync for TraceWriter
impl Unpin for TraceWriter
impl UnsafeUnpin for TraceWriter
impl UnwindSafe for TraceWriter
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