1pub struct DebugAltValue<T> {
2 value: T,
3}
4
5impl<T> From<T> for DebugAltValue<T> {
6 fn from(value: T) -> Self {
7 Self { value }
8 }
9}
10
11impl<T: std::fmt::Debug> std::fmt::Debug for DebugAltValue<T> {
12 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13 write!(f, "{:#?}", self.value)
14 }
15}
16
17#[macro_export]
18macro_rules! info_alt {
19 ($($expr:ident),* $(,)?, $msg:literal) => {
20 tracing::info!($($expr = ?$crate::debug::DebugAltValue::from(&$expr)),*, $msg)
21 };
22 ($($key:ident = $value:expr),* $(,)?, $msg:literal) => {
23 tracing::info!($($key = ?$crate::debug::DebugAltValue::from(&$value)),*, $msg)
24 };
25}
26#[macro_export]
27macro_rules! debug_alt {
28 ($($expr:ident),* $(,)?, $msg:literal) => {
29 tracing::debug!($($expr = ?$crate::debug::DebugAltValue::from(&$expr)),*, $msg)
30 };
31 ($($key:ident = $value:expr),* $(,)?, $msg:literal) => {
32 tracing::debug!($($key = ?$crate::debug::DebugAltValue::from(&$value)),*, $msg)
33 };
34}
35#[macro_export]
36macro_rules! trace_alt {
37 ($($expr:ident),* $(,)?, $msg:literal) => {
38 tracing::trace!($($expr = ?$crate::debug::DebugAltValue::from(&$expr)),*, $msg)
39 };
40 ($($key:ident = $value:expr),* $(,)?, $msg:literal) => {
41 tracing::trace!($($key = ?$crate::debug::DebugAltValue::from(&$value)),*, $msg)
42 };
43}
44
45pub struct RawString<'a>(pub &'a String);
46
47impl<'a> std::fmt::Debug for RawString<'a> {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 write!(f, "{}", self.0)
50 }
51}