Skip to main content

Crate etw_wrapper

Crate etw_wrapper 

Source
Expand description

A strongly typed Event Tracing for Windows wrapper.

The gen_etw_wrapper! macro turns an ETW manifest into a strongly typed provider struct. This crate supports Windows only.

use etw_wrapper::{Result, gen_etw_wrapper};

gen_etw_wrapper!("manifests/widgetservice.man", PROVIDER_WIDGETSERVICE -> WidgetLogger);

fn main() -> Result<()> {
    let provider = WidgetLogger::register()?;
    provider.request_failed(0x12ABCDEF, 500, 42, "failed to succeed")?;
    Ok(())
}

To avoid the procedural macro, call EtwLogger::register, optionally check EtwLogger::enabled before EtwLogger::write, and convert parameters to EventDataDescriptor instances with the helpers in the field module.

use etw_wrapper::{EtwLogger, EventDescriptor, Guid, field::*};
let ctx = EtwLogger::register(&Guid::default()).unwrap();
let x = 1u32;
let y = to_u16cstring("hello");

let descriptor = EventDescriptor::default();
ctx.write(&descriptor, &[scalar(&x), str16(&y).unwrap()]).unwrap();

Modules§

field
Serialization primitives that turn typed values into EventDataDescriptor instances.

Macros§

gen_etw_wrappermacro
Generates strongly typed ETW providers from an instrumentation manifest.

Structs§

EtwLogger
A registered ETW provider.
EventDescriptor
Describes an ETW event’s identity and filtering metadata. Describes an ETW event’s identity and filtering metadata.
FileTime
A Windows file time represented as 100-nanosecond intervals since January 1, 1601 UTC. A Windows file time represented as 100-nanosecond intervals since January 1, 1601 UTC.
Guid
A Windows globally unique identifier. A Windows globally unique identifier.
SystemTime
A Windows date and time with millisecond precision. A Windows date and time with millisecond precision.

Enums§

Error
An error reported while registering a provider or writing an event.

Type Aliases§

Result
A specialized Result for this crate’s fallible operations.