smos_application/helpers/logging.rs
1//! Fail-open logging helper.
2//!
3//! The `log_nonfatal!` macro unifies the `if let Err(e) = … { tracing::warn!(…) }`
4//! swallow pattern that recurs across the finalize / merge / save paths.
5//! Semantics are identical to the inlined form: the error is logged at WARN
6//! and execution continues. Structured fields are passed through verbatim —
7//! only the `error = %e` binding is injected by the macro itself, so callers
8//! must NOT repeat it.
9
10/// Log a non-fatal error at WARN and continue.
11///
12/// Expands to `if let Err(e) = … { tracing::warn!(error = %e, …) }`. The
13/// injected `error = %e` binding is the only thing the macro adds itself;
14/// callers pass any additional structured fields and the message literal
15/// verbatim. `tracing` accepts fields in any order before the message, so
16/// the injected `error = %e` is valid whether the caller adds fields or
17/// only a context string.
18#[macro_export]
19macro_rules! log_nonfatal {
20 ($result:expr, $($args:tt)*) => {
21 if let Err(e) = $result {
22 tracing::warn!(error = %e, $($args)*);
23 }
24 };
25}