aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src/fmt.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-06-07 03:21:09 +0200
committerDario Nieuwenhuis <[email protected]>2021-06-07 03:21:37 +0200
commit3be49d3e794d5819574fe33ffbfda9da1ddbe216 (patch)
tree30ac3b89de123efd2e6a6d9cc250783f9df6f699 /embassy-net/src/fmt.rs
parentef1ebefec0c682553213406b3e59a30a79520291 (diff)
fmt: Add dunmy use to avoid "unused variable" errors when no log is enabled.
Diffstat (limited to 'embassy-net/src/fmt.rs')
-rw-r--r--embassy-net/src/fmt.rs42
1 files changed, 26 insertions, 16 deletions
diff --git a/embassy-net/src/fmt.rs b/embassy-net/src/fmt.rs
index 2646c57ab..066970813 100644
--- a/embassy-net/src/fmt.rs
+++ b/embassy-net/src/fmt.rs
@@ -104,56 +104,66 @@ macro_rules! panic {
104} 104}
105 105
106macro_rules! trace { 106macro_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
117macro_rules! debug { 119macro_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
128macro_rules! info { 132macro_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
139macro_rules! warn { 145macro_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
150macro_rules! error { 158macro_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}