| Crates.io | log-args-runtime |
| lib.rs | log-args-runtime |
| version | 0.1.4 |
| created_at | 2025-07-13 07:05:24.768321+00 |
| updated_at | 2025-08-21 02:58:29.802454+00 |
| description | A simple procedural macro to log function arguments using the tracing crate. |
| homepage | https://github.com/MKJSM/log-args |
| repository | https://github.com/MKJSM/log-args |
| max_upload_size | |
| id | 1750062 |
| size | 29,528 |
Runtime support crate for the log_args procedural macros, providing context storage and enriched logging macros.
Note: This is part of the log-args workspace. For complete setup and usage examples, see the main documentation.
info!, warn!, error!, debug!, trace!) with automatic contextwith_context feature for JSON logging with flattened events[dependencies]
log-args-runtime = { version = "0.1.4", features = ["with_context"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
Note: The
with_contextfeature includes a structuredcontextfield in log events. Disable it if you only want direct field logging.
For structured JSON logging with context fields at the top level:
fn init_logging() {
tracing_subscriber::fmt()
.json()
.flatten_event(true)
.init();
}
use tracing::info;
fn main() {
init_logging();
// Push request-scoped context
log_args_runtime::push_context(|ctx| {
ctx.insert("tenant_id".into(), "acme".into());
ctx.insert("session_id".into(), "web".into());
});
// Logs include merged context when `with_context` is enabled
log_args_runtime::info!("Processing request");
}
Integration: When using
log_argsprocedural macros, they automatically redefine logging macros within annotated functions to include function parameters and span context.
This crate works in tandem with the log_args procedural macro:
log_args: Compile-time macro that rewrites functions to capture parameters and set up context propagationlog-args-runtime: Runtime support providing context storage and enriched logging macrosSee the workspace examples for complete demonstrations:
cargo run --example basic_usage
cargo run --example span_propagation
cargo run --example selective_fields
MIT - See LICENSE for details.