Control logging using key events
This commit is contained in:
parent
c3316ba995
commit
728d908d4a
6 changed files with 94 additions and 52 deletions
|
@ -1,48 +1,27 @@
|
|||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use log::{info, warn, LevelFilter};
|
||||
use log::LevelFilter;
|
||||
|
||||
pub mod core;
|
||||
pub mod utils;
|
||||
|
||||
use utils::{logger::LOGGER, splash::print_splash};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
#[arg(long, short, help = "Enable logging output")]
|
||||
log: bool,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let t = zephyr::add(0, 2);
|
||||
println!("{}", t);
|
||||
let cli = Cli::parse();
|
||||
|
||||
log::set_logger(&*LOGGER).unwrap();
|
||||
log::set_max_level(LevelFilter::Debug);
|
||||
|
||||
print_splash();
|
||||
|
||||
if cli.log {
|
||||
info!("Initializing Engine with logging to stdout enabled");
|
||||
LOGGER.write_to_stdout();
|
||||
|
||||
core::init_renderer()?;
|
||||
} else {
|
||||
LOGGER.write_to_stdout();
|
||||
info!("Initializing Engine with logging to stdout disabled");
|
||||
info!("Writing all logs to file z.log");
|
||||
let shell_thread = tokio::task::spawn(async { core::repl::repl::handle_repl().await });
|
||||
|
||||
LOGGER.write_to_file("z.log");
|
||||
info!("Logging back to file z.log");
|
||||
|
||||
let shell_thread = tokio::task::spawn(async {
|
||||
core::repl::repl::handle_repl().await
|
||||
});
|
||||
|
||||
core::init_renderer()?;
|
||||
shell_thread.await??; // LOL - Caz
|
||||
}
|
||||
core::init_renderer()?;
|
||||
let _ = shell_thread.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue