diff options
Diffstat (limited to 'embassy-extras/src/fmt.rs')
| -rw-r--r-- | embassy-extras/src/fmt.rs | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/embassy-extras/src/fmt.rs b/embassy-extras/src/fmt.rs index 2646c57ab..066970813 100644 --- a/embassy-extras/src/fmt.rs +++ b/embassy-extras/src/fmt.rs | |||
| @@ -104,56 +104,66 @@ macro_rules! panic { | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | macro_rules! trace { | 106 | macro_rules! trace { |
| 107 | ($($x:tt)*) => { | 107 | ($s:literal $(, $x:expr)* $(,)?) => { |
| 108 | { | 108 | { |
| 109 | #[cfg(feature = "log")] | 109 | #[cfg(feature = "log")] |
| 110 | ::log::trace!($($x)*); | 110 | ::log::trace!($s $(, $x)*); |
| 111 | #[cfg(feature = "defmt")] | 111 | #[cfg(feature = "defmt")] |
| 112 | ::defmt::trace!($($x)*); | 112 | ::defmt::trace!($s $(, $x)*); |
| 113 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 114 | let _ = ($( & $x ),*); | ||
| 113 | } | 115 | } |
| 114 | }; | 116 | }; |
| 115 | } | 117 | } |
| 116 | 118 | ||
| 117 | macro_rules! debug { | 119 | macro_rules! debug { |
| 118 | ($($x:tt)*) => { | 120 | ($s:literal $(, $x:expr)* $(,)?) => { |
| 119 | { | 121 | { |
| 120 | #[cfg(fevature = "log")] | 122 | #[cfg(feature = "log")] |
| 121 | ::log::debug!($($x)*); | 123 | ::log::debug!($s $(, $x)*); |
| 122 | #[cfg(feature = "defmt")] | 124 | #[cfg(feature = "defmt")] |
| 123 | ::defmt::debug!($($x)*); | 125 | ::defmt::debug!($s $(, $x)*); |
| 126 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 127 | let _ = ($( & $x ),*); | ||
| 124 | } | 128 | } |
| 125 | }; | 129 | }; |
| 126 | } | 130 | } |
| 127 | 131 | ||
| 128 | macro_rules! info { | 132 | macro_rules! info { |
| 129 | ($($x:tt)*) => { | 133 | ($s:literal $(, $x:expr)* $(,)?) => { |
| 130 | { | 134 | { |
| 131 | #[cfg(feature = "log")] | 135 | #[cfg(feature = "log")] |
| 132 | ::log::info!($($x)*); | 136 | ::log::info!($s $(, $x)*); |
| 133 | #[cfg(feature = "defmt")] | 137 | #[cfg(feature = "defmt")] |
| 134 | ::defmt::info!($($x)*); | 138 | ::defmt::info!($s $(, $x)*); |
| 139 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 140 | let _ = ($( & $x ),*); | ||
| 135 | } | 141 | } |
| 136 | }; | 142 | }; |
| 137 | } | 143 | } |
| 138 | 144 | ||
| 139 | macro_rules! warn { | 145 | macro_rules! warn { |
| 140 | ($($x:tt)*) => { | 146 | ($s:literal $(, $x:expr)* $(,)?) => { |
| 141 | { | 147 | { |
| 142 | #[cfg(feature = "log")] | 148 | #[cfg(feature = "log")] |
| 143 | ::log::warn!($($x)*); | 149 | ::log::warn!($s $(, $x)*); |
| 144 | #[cfg(feature = "defmt")] | 150 | #[cfg(feature = "defmt")] |
| 145 | ::defmt::warn!($($x)*); | 151 | ::defmt::warn!($s $(, $x)*); |
| 152 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 153 | let _ = ($( & $x ),*); | ||
| 146 | } | 154 | } |
| 147 | }; | 155 | }; |
| 148 | } | 156 | } |
| 149 | 157 | ||
| 150 | macro_rules! error { | 158 | macro_rules! error { |
| 151 | ($($x:tt)*) => { | 159 | ($s:literal $(, $x:expr)* $(,)?) => { |
| 152 | { | 160 | { |
| 153 | #[cfg(feature = "log")] | 161 | #[cfg(feature = "log")] |
| 154 | ::log::error!($($x)*); | 162 | ::log::error!($s $(, $x)*); |
| 155 | #[cfg(feature = "defmt")] | 163 | #[cfg(feature = "defmt")] |
| 156 | ::defmt::error!($($x)*); | 164 | ::defmt::error!($s $(, $x)*); |
| 165 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 166 | let _ = ($( & $x ),*); | ||
| 157 | } | 167 | } |
| 158 | }; | 168 | }; |
| 159 | } | 169 | } |
