rak_rs/util/
debug.rs

1/// A wrapper for println that is enabled only with the features `debug`, `debug_all`, or `debug_features`.
2/// - `debug` - Enables generic logging, purposeful for debugging things going wrong with your implementation
3/// - `debug_all` - Enables logging of all components, IE, connection, packets, etc.
4/// - `debug_buffers` - Enables logging of all buffers sent and received.
5#[macro_export]
6macro_rules! rakrs_debug {
7    ($heavy: ident, $($t: tt)*) => {
8        if cfg!(feature="debug") && cfg!(feature="debug_all") {
9            println!("[rakrs] DBG! {}", format!($($t)*));
10        }
11    };
12    ($($t: tt)*) => {
13        if cfg!(feature="debug") {
14            println!("[rakrs] DBG! {}", format!($($t)*));
15        }
16    };
17}
18
19#[macro_export]
20macro_rules! rakrs_debug_buffers {
21    ($server: literal, $($t: tt)*) => {
22        if cfg!(feature="debug_buffers") {
23            let x = if $server == true { "S -> C" } else { "C -> S" };
24            println!("[rakrs] DBG [{}]: {}", x, format!($($t)*));
25        }
26    };
27}