Use compile time env var to determine log level filter
This commit is contained in:
parent
eaa2a24efb
commit
e69a871c2a
|
|
@ -12,7 +12,7 @@ rustflags = [
|
|||
|
||||
|
||||
[env]
|
||||
ESP_LOG = "info"
|
||||
ESP_LOG = "warn"
|
||||
# This is overkill, but we can afford it.
|
||||
SLINT_FONT_SIZES = "8,11,10,12,13,14,15,16,18,20,22,24,32"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ repository = "https://github.com/haobogu/rmk"
|
|||
edition = "2024"
|
||||
|
||||
[features]
|
||||
default = ["usb-log", "limit-fps", "warn"]
|
||||
default = ["usb-log", "limit-fps"]
|
||||
# Make RMK not to use USB
|
||||
no-usb = ["rmk/_no_usb"]
|
||||
# Let RMK use BLE
|
||||
|
|
@ -26,12 +26,6 @@ rtt-log = ["dep:rtt-target", "dep:panic-rtt-target"]
|
|||
# which causes the LCD to glitch. To prevent the main core from spending all its
|
||||
# execution time on just driving the LCD, it will be limited.
|
||||
limit-fps = []
|
||||
# Log levels (lower takes precedence) TODO: Use env vars
|
||||
error = []
|
||||
warn = []
|
||||
info = []
|
||||
debug = []
|
||||
trace = []
|
||||
# Development profiles
|
||||
develop = ["limit-fps", "alt-log"]
|
||||
develop-usb = ["limit-fps", "usb-log", "no-usb", "ble"]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,27 @@ use core::fmt::Write;
|
|||
use critical_section::{CriticalSection, Mutex};
|
||||
use esp_hal::Blocking;
|
||||
use esp_hal::uart::UartTx;
|
||||
use log::Log;
|
||||
use log::{LevelFilter, Log};
|
||||
|
||||
pub const LOG_LEVEL_FILTER: LevelFilter = {
|
||||
if let Some(string) = option_env!("ESP_LOG") {
|
||||
if string.eq_ignore_ascii_case("ERROR") {
|
||||
LevelFilter::Error
|
||||
} else if string.eq_ignore_ascii_case("WARN") {
|
||||
LevelFilter::Warn
|
||||
} else if string.eq_ignore_ascii_case("INFO") {
|
||||
LevelFilter::Info
|
||||
} else if string.eq_ignore_ascii_case("DEBUG") {
|
||||
LevelFilter::Debug
|
||||
} else if string.eq_ignore_ascii_case("TRACE") {
|
||||
LevelFilter::Trace
|
||||
} else {
|
||||
panic!("Unknown `ESP_LOG` value. Only `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`, or `OFF` may be used.");
|
||||
}
|
||||
} else {
|
||||
LevelFilter::Off
|
||||
}
|
||||
};
|
||||
|
||||
static ALT_LOGGER_UART: Mutex<RefCell<Option<UartTx<'static, Blocking>>>> =
|
||||
Mutex::new(RefCell::new(None));
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, Status};
|
|||
use {esp_alloc as _, esp_backtrace as _};
|
||||
|
||||
use crate::keymap::{KEY_MESSAGE_CHANNEL, create_hid_report_interceptor};
|
||||
use crate::logging::LOG_LEVEL_FILTER;
|
||||
use crate::matrix::IoeMatrix;
|
||||
use crate::peripherals::st7701s::St7701s;
|
||||
use crate::ui::backend::{FramebufferPtr, SlintBackend};
|
||||
|
|
@ -90,22 +91,6 @@ mod console;
|
|||
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
||||
esp_bootloader_esp_idf::esp_app_desc!();
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "trace")] {
|
||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Trace;
|
||||
} else if #[cfg(feature = "debug")] {
|
||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Debug;
|
||||
} else if #[cfg(feature = "info")] {
|
||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Info;
|
||||
} else if #[cfg(feature = "warn")] {
|
||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Warn;
|
||||
} else if #[cfg(feature = "error")] {
|
||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Error;
|
||||
} else {
|
||||
const LOG_LEVEL_FILTER: LevelFilter = LevelFilter::Off;
|
||||
}
|
||||
}
|
||||
|
||||
// const FRAME_DURATION_MIN: Duration = Duration::from_millis(40); // 25 FPS
|
||||
const FRAME_DURATION_MIN: Duration = Duration::from_millis(100); // 10 FPS
|
||||
|
||||
|
|
@ -556,7 +541,7 @@ async fn run_lcd(mut st7701s: St7701s<'static, Blocking>, framebuffer: &'static
|
|||
#[cfg(not(feature = "limit-fps"))]
|
||||
while !transfer.is_done() {
|
||||
// Timer::after_millis(1).await;
|
||||
yield_now().await;
|
||||
rmk::embassy_futures::yield_now().await;
|
||||
}
|
||||
|
||||
let result;
|
||||
|
|
|
|||
Loading…
Reference in a new issue