TraceLogging for Rust

The tracelogging crate provides a simple and efficient system for logging TraceLogging events when the event schema is known at compile time.

This is similar to the C/C++ TraceLoggingProvider.h implementation in the Windows SDK.

```rust use tracelogging as tlg;

// Define a static variable for the "MyCompany.MyComponent" provider. tlg::defineprovider!( MYPROVIDER, // The static symbol to use for this provider. "MyCompany.MyComponent"); // The provider's name (string literal).

// Register the provider at module initialization. If you don't register (or if // register fails) then MYPROVIDER.enabled() will always return false, the // writeevent macro will be a no-op, and MYPROVIDER.unregister() will be a no-op. // Safety: MUST call MYPROVIDER.unregister() before module unload. unsafe { MY_PROVIDER.register(); }

// As necessary, call writeevent to send events to ETW. let field1value = "String Value"; let field2value = 42u32; tlg::writeevent!( MYPROVIDER, // The provider to use for the event. "MyEventName", // The event's name (string literal). level(Warning), // Event's severity level. keyword(0x23), // Event category bits. str8("Field1", field1value), // Add a string field to the event. u32("Field2", &field2_value), // Add an integer field to the event. );

// Before module unload, unregister the provider. MY_PROVIDER.unregister(); ```

Configuration

This crate supports the following configurable features:

In addition, this crate will log events only if compiled for a Windows operating system. If compiled for a non-Windows operating system, all logging operations will be no-ops.