feat(dashboard): Allow to hide spammy events

This commit is contained in:
Riccardo Zaglia 2023-09-05 15:16:01 +08:00
parent fbcf06bbee
commit 0b3fcad350
2 changed files with 37 additions and 13 deletions

View File

@ -3,11 +3,12 @@ use std::collections::VecDeque;
use alvr_common::LogSeverity;
use alvr_events::{Event, EventType};
use alvr_gui_common::theme::log_colors;
use alvr_session::Settings;
use alvr_session::{RawEventsConfig, Settings};
use eframe::{
egui::{Grid, RichText, ScrollArea, Ui},
epaint::Color32,
};
use settings_schema::Switch;
struct Entry {
color: Color32,
@ -17,7 +18,7 @@ struct Entry {
}
pub struct LogsTab {
show_raw_events: bool,
raw_events_config: Switch<RawEventsConfig>,
entries: VecDeque<Entry>,
log_limit: usize,
}
@ -25,14 +26,16 @@ pub struct LogsTab {
impl LogsTab {
pub fn new() -> Self {
Self {
show_raw_events: true,
raw_events_config: Switch::Enabled(RawEventsConfig {
hide_spammy_events: false,
}),
entries: VecDeque::new(),
log_limit: 1000,
}
}
pub fn update_settings(&mut self, settings: &Settings) {
self.show_raw_events = settings.logging.show_raw_events;
self.raw_events_config = settings.logging.show_raw_events.clone();
}
pub fn push_event(&mut self, event: Event) {
@ -67,13 +70,22 @@ impl LogsTab {
});
}
event_type => {
if self.show_raw_events {
self.entries.push_back(Entry {
color: log_colors::EVENT_LIGHT,
timestamp: event.timestamp,
ty: "EVENT".into(),
message: format!("{event_type:?}"),
});
if let Switch::Enabled(config) = &self.raw_events_config {
if !config.hide_spammy_events
|| !matches!(
event_type,
EventType::StatisticsSummary(_)
| EventType::GraphStatistics(_)
| EventType::Tracking(_)
)
{
self.entries.push_back(Entry {
color: log_colors::EVENT_LIGHT,
timestamp: event.timestamp,
ty: "EVENT".into(),
message: format!("{event_type:?}"),
});
}
}
}
}

View File

@ -827,6 +827,12 @@ For now works only on Windows+Nvidia"#
pub statistics_history_size: usize,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct RawEventsConfig {
#[schema(flag = "real-time")]
pub hide_spammy_events: bool,
}
#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct LoggingConfig {
pub client_log_report_level: Switch<LogSeverity>,
@ -841,7 +847,7 @@ pub struct LoggingConfig {
#[schema(flag = "real-time")]
pub notification_level: LogSeverity,
#[schema(flag = "real-time")]
pub show_raw_events: bool,
pub show_raw_events: Switch<RawEventsConfig>,
#[schema(strings(help = "This applies only to certain error or warning messages."))]
#[schema(flag = "steamvr-restart")]
pub prefer_backtrace: bool,
@ -1305,7 +1311,13 @@ pub fn session_settings_default() -> SettingsDefault {
LogSeverityDefaultVariant::Warning
},
},
show_raw_events: false,
show_raw_events: SwitchDefault {
enabled: false,
content: RawEventsConfigDefault {
gui_collapsed: true,
hide_spammy_events: false,
},
},
prefer_backtrace: false,
},
steamvr_launcher: SteamvrLauncherDefault {