implement log localization config generation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use std::{collections::HashMap, sync::Mutex};
|
||||
use std::{collections::{BTreeMap, HashMap}, sync::Mutex};
|
||||
use serde::Serialize;
|
||||
use strum::{EnumIter, IntoEnumIterator};
|
||||
use strum_macros::IntoStaticStr;
|
||||
|
||||
use esp_idf_svc::systime::EspSystemTime;
|
||||
@@ -129,7 +130,7 @@ mod tests {
|
||||
|
||||
|
||||
|
||||
#[derive(IntoStaticStr)]
|
||||
#[derive(IntoStaticStr, EnumIter, Serialize, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||
pub enum LogMessage {
|
||||
#[strum(serialize = "Reset due to {{txt_long}} requires rtc clear {{a}} and force config mode {{b}}")]
|
||||
reset_reason,
|
||||
@@ -155,4 +156,15 @@ pub enum LogMessage {
|
||||
mqtt_stay_alive_rec,
|
||||
#[strum(serialize = "Unknown topic recieved {{txt_long}}")]
|
||||
unknown_topic,
|
||||
}
|
||||
}
|
||||
|
||||
impl LogMessage {
|
||||
pub fn to_log_localisation_config() -> BTreeMap<LogMessage,&'static str> {
|
||||
let mut data = BTreeMap::new();
|
||||
for msg_type in LogMessage::iter() {
|
||||
let s: &'static str = msg_type.clone().into();
|
||||
data.insert(msg_type, s);
|
||||
}
|
||||
data
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user