[−][src]Trait ferrisetw::trace::TraceBaseTrait
Base trait for a Trace
This trait define the general methods required to control an ETW Session
Required methods
fn set_trace_name(&mut self, name: &str)
[−]
Internal function to set TraceName. See TraceTrait::named
fn set_trace_properties(self, props: TraceProperties) -> Self
[−]
The set_trace_properties
function sets the ETW session configuration properties
Arguments
props
- TraceProperties to set
Example
let mut props = TraceProperties::default(); props.flush_timer = 60; let my_trace = UserTrace::new().set_trace_properties(props);
fn enable(self, provider: Provider) -> Self
[−]
The enable
function enables a Provider for the Trace
Arguments
provider
- Provider to enable
Remarks
Multiple providers can be enabled for the same trace, as long as they are from the same CPU privilege
Example
let provider = Provider::new() .by_name("Microsoft-Windows-DistributedCOM") .add_callback(|record, schema| { println!("{}", record.EventHeader.ProcessId); }) .build()?; let my_trace = UserTrace::new().enable(provider);
fn open(self) -> Result<Self, TraceError> where
Self: Sized,
[−]
Self: Sized,
The open
function opens a Trace session
Remark
This function can fail, if it does it will return a TraceError accordingly
Example
let my_trace = UserTrace::new().open()?;
fn start(self) -> Result<Self, TraceError> where
Self: Sized,
[−]
Self: Sized,
The start
function starts a Trace session, this includes open and process the trace
Safety Note
This function will spawn a new thread, ETW blocks the thread listening to events, so we need a new thread to which delegate this process.
This function can fail, if it does it will return a TraceError
Example
let my_trace = UserTrace::new().start()?;
fn process(self) -> Result<Self, TraceError> where
Self: Sized,
[−]
Self: Sized,
The process
function will start processing a Trace session
Safety Note
This function will spawn the new thread which starts listening for events.
See ProcessTrace
Remarks
This function can fail, if it does it will return a TraceError
Example
UserTrace::new().open()?.process()?;
fn stop(&mut self)
[−]
The stop
function stops a Trace session
Safety Note
Since a call to start
will block thread and in case we want to execute it within a thread
we would -- for now -- have to move it to the context of the new thread, this function is
called from the Drop implementation.
This function will log if it fails