Improve verbosity levels
This commit is contained in:
parent
980e84b0f6
commit
56dd74b65f
1 changed files with 31 additions and 15 deletions
46
src/main.rs
46
src/main.rs
|
|
@ -13,8 +13,10 @@ use directories::ProjectDirs;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use state::AppState;
|
use state::AppState;
|
||||||
use tokio::{select, signal::unix::SignalKind};
|
use tokio::{select, signal::unix::SignalKind};
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info, Level};
|
||||||
use tracing_subscriber::filter::LevelFilter;
|
use tracing_subscriber::{
|
||||||
|
filter::Targets, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
|
|
@ -31,23 +33,37 @@ struct Args {
|
||||||
/// Path to the config file.
|
/// Path to the config file.
|
||||||
#[arg(long, short)]
|
#[arg(long, short)]
|
||||||
config: Option<PathBuf>,
|
config: Option<PathBuf>,
|
||||||
/// Enable more verbose output
|
/// Enable increasingly more verbose output
|
||||||
#[arg(long, short)]
|
#[arg(long, short, action = clap::ArgAction::Count)]
|
||||||
verbose: bool,
|
verbose: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_up_logging(verbose: bool) {
|
fn set_up_logging(verbose: u8) {
|
||||||
if verbose {
|
let filter = Targets::new()
|
||||||
tracing_subscriber::fmt()
|
.with_default(Level::TRACE)
|
||||||
.with_max_level(LevelFilter::TRACE)
|
.with_target("sqlx", Level::INFO);
|
||||||
.pretty()
|
match verbose {
|
||||||
.init();
|
0 => tracing_subscriber::fmt()
|
||||||
} else {
|
.with_max_level(Level::INFO)
|
||||||
tracing_subscriber::fmt()
|
|
||||||
.with_max_level(LevelFilter::INFO)
|
|
||||||
.without_time()
|
.without_time()
|
||||||
.with_target(false)
|
.with_target(false)
|
||||||
.init();
|
.init(),
|
||||||
|
1 => tracing_subscriber::fmt()
|
||||||
|
.with_max_level(Level::TRACE)
|
||||||
|
.with_target(false)
|
||||||
|
.finish()
|
||||||
|
.with(filter)
|
||||||
|
.init(),
|
||||||
|
2 => tracing_subscriber::fmt()
|
||||||
|
.with_max_level(Level::TRACE)
|
||||||
|
.pretty()
|
||||||
|
.finish()
|
||||||
|
.with(filter)
|
||||||
|
.init(),
|
||||||
|
_ => tracing_subscriber::fmt()
|
||||||
|
.with_max_level(Level::TRACE)
|
||||||
|
.pretty()
|
||||||
|
.init(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue