use std::sync::Arc;
use flight_entity::{EntityRuntimeSlot, Ref};
use flight_log::{LogLevel, LogSink};
pub type DebugSubsystemName = String;
pub type DebugGuardBinding = Arc<dyn Fn() + Send + Sync>;
#[derive(Clone, Default)]
pub struct DebugSubsystemHooks {
pub channels: Option<Vec<String>>,
pub disable_guards: Option<DebugGuardBinding>,
pub enable_guards: Option<DebugGuardBinding>,
}
#[derive(Clone, Default)]
pub struct DebugOptions {
pub channels: Option<Vec<String>>,
pub level: Option<LogLevel>,
pub sink: Option<LogSink>,
pub subsystems: Option<Vec<DebugSubsystemName>>,
}
pub struct DebugState {
runtime: EntityRuntimeSlot,
pub(crate) enabled: bool,
pub(crate) enabled_subsystems: Vec<DebugSubsystemHooks>,
pub(crate) frame_number: i64,
pub(crate) installed_sink: Option<LogSink>,
pub(crate) saved_channel_levels: Vec<(String, Option<LogLevel>)>,
pub(crate) saved_global_level: LogLevel,
pub(crate) subsystems: Vec<(DebugSubsystemName, DebugSubsystemHooks)>,
}
pub type DebugStateRef = Ref<DebugState>;
impl Default for DebugState {
fn default() -> Self {
return DebugState {
runtime: EntityRuntimeSlot::default(),
enabled: false,
enabled_subsystems: Vec::new(),
frame_number: 0,
installed_sink: None,
saved_channel_levels: Vec::new(),
saved_global_level: LogLevel::Verbose,
subsystems: Vec::new(),
};
}
}
flight_entity::impl_entity!(DebugState);