log_args_runtime/lib.rs
1//! log-args-runtime
2//!
3//! This crate provides runtime support for the `log-args` procedural macro crate.
4//! It exposes thread-local storage for propagating structured logging context (such as parent spans)
5//! at runtime. This crate is used internally by macro-generated code and is not intended for direct use
6//! by end users.
7//!
8//! # Usage
9//!
10//! Most users do not need to interact with this crate directly. If you are developing custom integrations,
11//! you can use the `__PARENT_LOG_ARGS` thread-local variable to set or retrieve the current parent log context.
12//!
13//! ```rust
14//! use log_args_runtime::__PARENT_LOG_ARGS;
15//!
16//! __PARENT_LOG_ARGS.with(|parent| {
17//! *parent.borrow_mut() = Some("parent-context".to_string());
18//! });
19//!
20//! __PARENT_LOG_ARGS.with(|parent| {
21//! if let Some(ctx) = &*parent.borrow() {
22//! println!("Current parent context: {}", ctx);
23//! }
24//! });
25//! ```
26use std::cell::RefCell;
27
28thread_local! {
29 pub static __PARENT_LOG_ARGS: RefCell<Option<String>> = RefCell::new(None);
30}