add log level "Notice", hide startup messages
This commit is contained in:
parent
19de229bb2
commit
346239ae6d
17
src/hud.rs
17
src/hud.rs
|
@ -54,6 +54,7 @@ pub enum LogLevel {
|
|||
//Debug,
|
||||
Chat,
|
||||
//Ping,
|
||||
Notice,
|
||||
}
|
||||
|
||||
struct Message {
|
||||
|
@ -82,6 +83,10 @@ impl Log {
|
|||
self.add(message, "WARNING".to_string(), LogLevel::Warning);
|
||||
}
|
||||
|
||||
pub fn notice(&mut self, message: String) {
|
||||
self.add(message, "".to_string(), LogLevel::Notice);
|
||||
}
|
||||
|
||||
pub fn add(&mut self, message: String, sender: String, level: LogLevel) {
|
||||
if self.logs.len() == LOG_MAX {
|
||||
self.logs.pop_front();
|
||||
|
@ -115,8 +120,8 @@ fn setup(
|
|||
mut log: ResMut<Log>,
|
||||
mut ambient_light: ResMut<AmbientLight>,
|
||||
) {
|
||||
log.info("Resuming from suspend".to_string());
|
||||
log.warning("Oxygen Low".to_string());
|
||||
log.notice("Resuming from suspend".to_string());
|
||||
log.notice("WARNING: Oxygen Low".to_string());
|
||||
let visibility = if settings.hud_active {
|
||||
Visibility::Inherited
|
||||
} else {
|
||||
|
@ -449,12 +454,16 @@ fn update(
|
|||
LogLevel::Chat => true,
|
||||
LogLevel::Warning => true,
|
||||
LogLevel::Info => true,
|
||||
//_ => false
|
||||
_ => false
|
||||
}}
|
||||
};
|
||||
let logs_vec: Vec<String> = log.logs.iter()
|
||||
.filter(logfilter)
|
||||
.map(|s| format!("{}: {}", s.sender, s.text)).collect();
|
||||
.map(|s| if s.sender.is_empty() {
|
||||
format!("{}", s.text)
|
||||
} else {
|
||||
format!("{}: {}", s.sender, s.text)
|
||||
}).collect();
|
||||
chat.sections[0].value = logs_vec.join("\n");
|
||||
}
|
||||
log.needs_rerendering = false;
|
||||
|
|
Loading…
Reference in a new issue