Skip to content

Commit 09ecf28

Browse files
jonathanpallanteldruin
authored andcommitted
Support having no logs at all.
1 parent c487a1a commit 09ecf28

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

src/fat/volume.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
//! FAT volume
22
3-
#[cfg(feature = "log")]
4-
use log::{debug, trace, warn};
5-
6-
#[cfg(feature = "defmt-log")]
7-
use defmt::{debug, trace, warn};
8-
93
use crate::{
4+
debug,
105
fat::{
116
Bpb, Fat16Info, Fat32Info, FatSpecificInfo, FatType, InfoSector, OnDiskDirEntry,
127
RESERVED_ENTRIES,
138
},
14-
Attributes, Block, BlockCount, BlockDevice, BlockIdx, Cluster, DirEntry, Directory, Error,
15-
ShortFileName, TimeSource, VolumeManager, VolumeType,
9+
trace, warn, Attributes, Block, BlockCount, BlockDevice, BlockIdx, Cluster, DirEntry,
10+
Directory, Error, ShortFileName, TimeSource, VolumeManager, VolumeType,
1611
};
1712
use byteorder::{ByteOrder, LittleEndian};
1813
use core::convert::TryFrom;

src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,36 @@ pub use volume_mgr::VolumeManager;
107107
#[deprecated]
108108
pub use volume_mgr::VolumeManager as Controller;
109109

110+
#[cfg(all(feature = "defmt-log", feature = "log"))]
111+
compile_error!("Cannot enable both log and defmt-log");
112+
113+
#[cfg(feature = "log")]
114+
use log::{debug, trace, warn};
115+
116+
#[cfg(feature = "defmt-log")]
117+
use defmt::{debug, trace, warn};
118+
119+
#[cfg(all(not(feature = "defmt-log"), not(feature = "log")))]
120+
#[macro_export]
121+
/// Like log::debug! but does nothing at all
122+
macro_rules! debug {
123+
($($arg:tt)+) => {};
124+
}
125+
126+
#[cfg(all(not(feature = "defmt-log"), not(feature = "log")))]
127+
#[macro_export]
128+
/// Like log::trace! but does nothing at all
129+
macro_rules! trace {
130+
($($arg:tt)+) => {};
131+
}
132+
133+
#[cfg(all(not(feature = "defmt-log"), not(feature = "log")))]
134+
#[macro_export]
135+
/// Like log::warn! but does nothing at all
136+
macro_rules! warn {
137+
($($arg:tt)+) => {};
138+
}
139+
110140
// ****************************************************************************
111141
//
112142
// Public Types

src/sdcard/mod.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,15 @@
77
88
pub mod proto;
99

10-
use super::{Block, BlockCount, BlockDevice, BlockIdx};
10+
use crate::{trace, Block, BlockCount, BlockDevice, BlockIdx};
1111
use core::cell::RefCell;
1212
use proto::*;
1313

1414
// =============================================================================
1515
// Imports
1616
// =============================================================================
1717

18-
#[cfg(feature = "log")]
19-
use log::{debug, trace, warn};
20-
21-
#[cfg(feature = "defmt-log")]
22-
use defmt::{debug, trace, warn};
23-
24-
#[cfg(all(feature = "defmt-log", feature = "log"))]
25-
compile_error!("Cannot enable both log and defmt-log");
26-
27-
#[cfg(all(not(feature = "defmt-log"), not(feature = "log")))]
28-
compile_error!("Must enable either log or defmt-log");
18+
use crate::{debug, warn};
2919

3020
// =============================================================================
3121
// Constants
@@ -141,14 +131,14 @@ where
141131
&self,
142132
blocks: &mut [Block],
143133
start_block_idx: BlockIdx,
144-
reason: &str,
134+
_reason: &str,
145135
) -> Result<(), Self::Error> {
146136
let mut inner = self.inner.borrow_mut();
147137
debug!(
148138
"Read {} blocks @ {} for {}",
149139
blocks.len(),
150140
start_block_idx.0,
151-
reason
141+
_reason
152142
);
153143
inner.check_init()?;
154144
inner.read(blocks, start_block_idx)
@@ -415,9 +405,9 @@ where
415405
Ok(R1_IDLE_STATE) => {
416406
break;
417407
}
418-
Ok(r) => {
408+
Ok(_r) => {
419409
// Try again
420-
warn!("Got response: {:x}, trying again..", r);
410+
warn!("Got response: {:x}, trying again..", _r);
421411
}
422412
}
423413

src/volume_mgr.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33
use byteorder::{ByteOrder, LittleEndian};
44
use core::convert::TryFrom;
55

6-
#[cfg(feature = "log")]
7-
use log::debug;
8-
9-
#[cfg(feature = "defmt-log")]
10-
use defmt::debug;
11-
126
use crate::fat::{self, RESERVED_ENTRIES};
137
use crate::filesystem::{
148
Attributes, Cluster, DirEntry, Directory, File, Mode, ShortFileName, TimeSource, MAX_FILE_SIZE,
159
};
1610
use crate::{
17-
Block, BlockCount, BlockDevice, BlockIdx, Error, Volume, VolumeIdx, VolumeType,
11+
debug, Block, BlockCount, BlockDevice, BlockIdx, Error, Volume, VolumeIdx, VolumeType,
1812
PARTITION_ID_FAT16, PARTITION_ID_FAT16_LBA, PARTITION_ID_FAT32_CHS_LBA, PARTITION_ID_FAT32_LBA,
1913
};
2014

0 commit comments

Comments
 (0)