Skip to main content

html2text/
macros.rs

1#[cfg(feature = "html_trace_bt")]
2extern crate backtrace;
3
4/* This is to work around a false positive for the clippy warning
5 * `match_on_same_arms`.
6 * See https://github.com/Manishearth/rust-clippy/issues/1390
7 */
8#[cfg(not(feature = "html_trace"))]
9#[inline(always)]
10pub fn nop() {}
11
12#[cfg(feature = "html_trace")]
13#[macro_export]
14#[doc(hidden)]
15macro_rules! html_trace {
16    ($fmt:expr) => {
17         #[cfg(feature = "html_trace_bt")]
18         {
19             let bt = ::backtrace::Backtrace::new();
20             log::info!( concat!($fmt, " at {:?}"), bt );
21         }
22         #[cfg(not(feature = "html_trace_bt"))]
23         {
24             log::info!($fmt);
25         }
26    };
27    ($fmt:expr, $( $args:expr ),*) => {
28         #[cfg(feature = "html_trace_bt")]
29         {
30             let bt = ::backtrace::Backtrace::new();
31             log::info!( concat!($fmt, " at {:?}"), $( $args ),* , bt );
32         }
33         #[cfg(not(feature = "html_trace_bt"))]
34         {
35             log::info!($fmt, $( $args ),*);
36         }
37    };
38}
39#[cfg(not(feature = "html_trace"))]
40#[macro_export]
41#[doc(hidden)]
42macro_rules! html_trace {
43    ($fmt:expr_2021) => {
44        $crate::macros::nop();
45    };
46    ($fmt:expr_2021, $( $args:expr_2021 ),*) => {
47        $crate::macros::nop();
48    };
49}
50
51#[cfg(feature = "html_trace")]
52#[macro_export]
53#[doc(hidden)]
54macro_rules! html_trace_quiet {
55    ($fmt:expr) => {
56         log::trace!( $fmt );
57    };
58    ($fmt:expr, $( $args:expr ),*) => {
59         log::trace!( $fmt, $( $args ),* );
60    };
61}
62
63#[cfg(not(feature = "html_trace"))]
64#[macro_export]
65#[doc(hidden)]
66macro_rules! html_trace_quiet {
67    ($fmt:expr_2021) => {
68        $crate::macros::nop();
69    };
70    ($fmt:expr_2021, $( $args:expr_2021 ),*) => {
71        $crate::macros::nop();
72    };
73}