Skip to content

Commit

Permalink
Adding logging macros
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Feb 26, 2024
1 parent bec5093 commit 495c09a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#[cfg(feature = "log")]
macro_rules! usb_log {
(trace, $($arg:expr),*) => { log::trace!($($arg),*) };
(debug, $($arg:expr),*) => { log::trace!($($arg),*) };
}

#[cfg(feature = "defmt")]
macro_rules! net_log {
(trace, $($arg:expr),*) => { defmt::trace!($($arg),*) };
(debug, $($arg:expr),*) => { defmt::debug!($($arg),*) };
}

#[cfg(not(any(feature = "log", feature = "defmt")))]
macro_rules! usb_log {
($level:ident, $($arg:expr),*) => {{ $( let _ = $arg; )* }}
}

macro_rules! usb_trace {
($($arg:expr),*) => (usb_log!(trace, $($arg),*));
}

macro_rules! usb_debug {
($($arg:expr),*) => (usb_log!(debug, $($arg),*));
}

0 comments on commit 495c09a

Please sign in to comment.