Add cli arg for log level to playground (#343)

## Description
Fixes #305 

`cargo run -- -l trace`

Uses `Level`'s `FromStr` impl, which accepts numbers 1-5 or
case-insensitive level names. Default level is `Level::DEBUG`
This commit is contained in:
Gingeh 2023-05-28 22:57:07 +10:00 committed by GitHub
parent e3c0aec967
commit e5de2d3f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -5,6 +5,7 @@ edition.workspace = true
[dependencies]
anyhow = "1.0.65"
clap = { version = "4", features = ["derive"] }
glam = "0.23.0"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"

View file

@ -16,6 +16,7 @@
clippy::dbg_macro
)]
use clap::Parser;
use tracing::Level;
use valence::app::App;
@ -23,9 +24,17 @@ use valence::app::App;
mod extras;
mod playground;
#[derive(Parser)]
struct Args {
#[arg(short, default_value_t = Level::DEBUG)]
log_level: Level,
}
fn main() {
let args = Args::parse();
tracing_subscriber::fmt()
.with_max_level(Level::DEBUG)
.with_max_level(args.log_level)
.init();
let mut app = App::new();