wide_log!() { /* proc-macro */ }Expand description
The wide_log! proc-macro. See the crate-level documentation
for syntax and usage details.
Takes a JSON object literal as its only parameter. The JSON structure defines all keys, their nesting/paths, default values, and which keys are counters or durations. The macro generates:
- The
EventKeyenum (#[repr(u8)], one variant per unique JSON key) - The
Keytrait impl (as_str,MAX_KEYS,as_index,DURATION_PATH,TIMESTAMP_PATH,ID_PATH) __wl_resolve_path— compile-time path resolution function- Thread-local storage (
CURRENT_EVENT: ContextCell<WideEvent<EventKey>>) default_emit— serializes viasonic_rsand writes the JSON line to non-blocking stdout viastdout_emit::submitWideLogGuardBuilder— builder for constructing guards with timezone, ID generator, and emit functionWideLogGuard— guard type (constructed viabuilder().build())current()— returns the innermost active eventscope()/scope_default()(behindtokiofeature)WideLogLayertower middleware (behindtokiofeature)- All logging macros:
wl_set!,wl_inc!,wl_dec!,wl_add!,wl_null!,info!,warn!,error!,debug!,trace!
§Value Markers
| Marker | Meaning |
|---|---|
duration! | Duration leaf; set to elapsed ms on drop |
counter! | Incrementable counter; init to 0 (absent) |
null | No default value; set via wl_set! |
"literal" | String default; set on guard creation |
123 | Numeric default; set on guard creation |
true/false | Boolean default; set on guard creation |
§Duration Auto-Add Rules
If no "duration" key is declared, the macro adds
"duration": { "total_ms": duration! } automatically. See the README for
the full duration resolution table.
§Event Auto-Add Rules
If no "event" key is declared, the macro adds
"event": { "timestamp": null, "id": null } automatically.
The timestamp is set to an RFC 3339 string on drop.
The id is set to a ULID string (or UUIDv4 with the uuid feature)
on build().