Skip to content

Commit 15760d8

Browse files
committed
feat: disable debug logs on release versions
1 parent eacd680 commit 15760d8

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ esp32 = ["esp-backtrace/esp32", "esp-hal/esp32", "esp-println/esp32", "esp-wifi/
5656
esp32c3 = ["esp-backtrace/esp32c3", "esp-hal/esp32c3", "esp-println/esp32c3", "esp-wifi/esp32c3", "esp-hal-embassy/esp32c3", "esp-storage/esp32c3", "esp-hal-wifimanager/esp32c3", "esp-hal-ota/esp32c3", "dep:esp32c3", "dep:mfrc522-02"]
5757
gen_version = []
5858
bat_dev_lcd = []
59+
release_build = []
5960

6061
[profile.dev]
6162
# Rust debug is too slow.

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fn main() {
2525
let src_crc = hasher.finalize();
2626

2727
let version_str = if let Ok(rel) = std::env::var("RELEASE_BUILD") {
28+
println!("cargo:rustc-cfg=feature=\"release_build\"");
2829
rel
2930
} else {
3031
let epoch = std::time::SystemTime::now()

src/utils/logger.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ use alloc::string::String;
33
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, channel::Channel};
44

55
const MAX_LOGS_SIZE: usize = 100;
6-
pub const FILTER_MAX: log::LevelFilter = log::LevelFilter::Debug;
76
pub static LOGS_CHANNEL: Channel<CriticalSectionRawMutex, String, MAX_LOGS_SIZE> = Channel::new();
87

8+
#[cfg(feature = "release_build")]
9+
pub const FILTER_MAX: log::LevelFilter = log::LevelFilter::Info;
10+
11+
#[cfg(not(feature = "release_build"))]
12+
pub const FILTER_MAX: log::LevelFilter = log::LevelFilter::Debug;
13+
914
pub struct FkmLogger;
1015

1116
impl FkmLogger {

0 commit comments

Comments
 (0)