Expand description
log-args-runtime
Runtime support for the log_args
procedural macros. This crate provides:
- Context storage and helpers to push/pop context across sync and async boundaries
- Logging macros (
info!
,warn!
,error!
,debug!
,trace!
) that automatically merge inherited context into your events log_with_context!
which enriches an underlyingtracing
macro
Feature flags
with_context
(off by default): When enabled, the runtime includes acontext
field (debug-formatted map) in each log when there is context available. Configure yourtracing-subscriber
JSON formatter with.flatten_event(true)
to surface the fields at the top level in JSON output.
Quick start
use tracing::{info, Level};
fn init() {
tracing_subscriber::fmt().json().flatten_event(true).with_max_level(Level::DEBUG).init();
}
fn main() {
init();
log_args_runtime::info!("hello");
}
Macros§
- debug
- error
- info
- Global context-aware logging macros that inherit parent context These can be used in any function to automatically include context from parent functions with span
- log_
with_ context - trace
- warn
Structs§
- Async
Context Guard - Guard for async context that automatically pops on drop
Constants§
Functions§
- auto_
capture_ context - Automatically capture and preserve current context for function execution This ensures context is maintained across function boundaries without user intervention
- capture_
context - Capture current context and store it globally for cross-boundary persistence This function is automatically called by the macro to ensure context is preserved
- get_
context_ value - get_
global_ context - Get global context for cross-boundary persistence
- get_
inherited_ context_ string - Get inherited context as a formatted string for automatic span propagation This function retrieves all context fields from the current span context and formats them as a string for logging
- get_
inherited_ fields_ map - Get inherited context fields as individual key-value pairs This function returns a HashMap of inherited context fields for dynamic field injection
- set_
global_ context - Set global context that persists across all boundaries