2022-01-22 00:01:16 -06:00
|
|
|
use log::LevelFilter;
|
2022-02-04 18:47:05 -06:00
|
|
|
// use rkyv::{Deserialize, Serialize};
|
2022-01-22 01:26:25 -06:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-01-22 00:01:16 -06:00
|
|
|
|
|
|
|
#[derive(Serialize, Debug, Deserialize)]
|
|
|
|
pub enum LogLevel {
|
|
|
|
/// A level lower than all log levels.
|
|
|
|
Off,
|
|
|
|
/// Corresponds to the `Error` log level.
|
|
|
|
Error,
|
|
|
|
/// Corresponds to the `Warn` log level.
|
|
|
|
Warn,
|
|
|
|
/// Corresponds to the `Info` log level.
|
|
|
|
Info,
|
|
|
|
/// Corresponds to the `Debug` log level.
|
|
|
|
Debug,
|
|
|
|
/// Corresponds to the `Trace` log level.
|
|
|
|
Trace,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Debug, Deserialize)]
|
|
|
|
pub struct BootConfig {
|
|
|
|
pub logging_level: LogLevel,
|
2022-01-25 19:40:37 -06:00
|
|
|
pub logger_padding: usize,
|
2022-01-22 00:01:16 -06:00
|
|
|
pub run_tests: bool,
|
|
|
|
pub run_demos: bool,
|
|
|
|
pub run_shader_tests: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BootConfig {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
let data = include_str!("../assets/kernel_config.json");
|
|
|
|
|
|
|
|
// Parse the string of data into a Person object. This is exactly the
|
|
|
|
// same function as the one that produced serde_json::Value above, but
|
|
|
|
// now we are asking it for a Person as output.
|
|
|
|
let p: BootConfig = serde_json::from_str(data).unwrap();
|
2022-01-25 19:40:37 -06:00
|
|
|
// info!("{:?}", p);
|
2022-01-22 00:01:16 -06:00
|
|
|
p
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn log_level(&self) -> LevelFilter {
|
|
|
|
use LevelFilter::*;
|
|
|
|
match self.logging_level {
|
|
|
|
LogLevel::Off => Off,
|
|
|
|
LogLevel::Error => Error,
|
|
|
|
LogLevel::Warn => Warn,
|
|
|
|
LogLevel::Info => Info,
|
|
|
|
LogLevel::Debug => Debug,
|
|
|
|
LogLevel::Trace => Trace,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|