Debian Codegraph @

debian/rust-vendor/jiff-core/src/logging.rs

raw
1 // Some feature combinations result in some of these macros never being used.
2 // Which is fine. Just squash the warnings.
3 #![allow(dead_code, unused_macros)]
4
5 macro_rules! log {
6 ($($tt:tt)*) => {
7 #[cfg(feature = "logging")]
8 {
9 $($tt)*
10 }
11 }
12 }
13
14 macro_rules! error {
15 ($($tt:tt)*) => { log!(log::error!($($tt)*)) }
16 }
17
18 macro_rules! warn {
19 ($($tt:tt)*) => { log!(log::warn!($($tt)*)) }
20 }
21
22 macro_rules! info {
23 ($($tt:tt)*) => { log!(log::info!($($tt)*)) }
24 }
25
26 macro_rules! debug {
27 ($($tt:tt)*) => { log!(log::debug!($($tt)*)) }
28 }
29
30 macro_rules! trace {
31 ($($tt:tt)*) => { log!(log::trace!($($tt)*)) }
32 }
33
34 /// A copy of std's `dbg!` macro that doesn't do pretty printing.
35 ///
36 /// This is nice because we usually want more compact output in this crate.
37 /// Also, because we don't import std's prelude, we have to use `std::dbg!`.
38 /// This macro definition makes it available as `dbg!`.
39 #[cfg(feature = "std")]
40 macro_rules! dbg {
41 () => {
42 std::eprintln!(
43 "[{}:{}:{}]",
44 $crate::file!(),
45 $crate::line!(),
46 $crate::column!(),
47 )
48 };
49 ($val:expr $(,)?) => {
50 match $val {
51 tmp => {
52 std::eprintln!(
53 "[{}:{}:{}] {} = {:?}",
54 std::file!(),
55 std::line!(),
56 std::column!(),
57 std::stringify!($val),
58 &tmp,
59 );
60 tmp
61 }
62 }
63 };
64 ($($val:expr),+ $(,)?) => {
65 ($(dbg!($val)),+,)
66 };
67 }