Use --verbose instead of RUST_LOG
This commit is contained in:
parent
de767121be
commit
e76c94a57c
4 changed files with 20 additions and 75 deletions
66
Cargo.lock
generated
66
Cargo.lock
generated
|
|
@ -29,15 +29,6 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.16"
|
||||
|
|
@ -879,15 +870,6 @@ version = "0.4.19"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
dependencies = [
|
||||
"regex-automata 0.1.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.7.1"
|
||||
|
|
@ -1225,50 +1207,6 @@ dependencies = [
|
|||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata 0.3.4",
|
||||
"regex-syntax 0.7.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax 0.6.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax 0.7.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rsa"
|
||||
version = "0.9.2"
|
||||
|
|
@ -2007,14 +1945,10 @@ version = "0.3.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
|
||||
dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ rust-embed = "6.8.1"
|
|||
sqlx = { version = "0.7.1", features = ["runtime-tokio", "sqlite"] }
|
||||
tokio = { version = "1.29.1", features = ["full"] }
|
||||
tracing = "0.1.37"
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
tracing-subscriber = "0.3.17"
|
||||
|
||||
[build-dependencies]
|
||||
vergen = { version = "8.2.4", features = ["git", "gitcl"] }
|
||||
|
|
|
|||
24
src/main.rs
24
src/main.rs
|
|
@ -22,14 +22,23 @@ struct Args {
|
|||
db: PathBuf,
|
||||
/// Path to the git repo.
|
||||
repo: PathBuf,
|
||||
/// Enable more verbose output
|
||||
#[arg(long, short)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
fn set_up_logging() {
|
||||
let filter = tracing_subscriber::filter::Builder::default()
|
||||
.with_default_directive(LevelFilter::INFO.into())
|
||||
.from_env_lossy();
|
||||
|
||||
tracing_subscriber::fmt().with_env_filter(filter).init();
|
||||
fn set_up_logging(verbose: bool) {
|
||||
if verbose {
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(LevelFilter::DEBUG)
|
||||
.init();
|
||||
} else {
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(LevelFilter::INFO)
|
||||
.without_time()
|
||||
.with_target(false)
|
||||
.init();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
|
|
@ -49,10 +58,9 @@ async fn index(State(db): State<SqlitePool>) -> Result<Response, Response> {
|
|||
}
|
||||
|
||||
async fn run() -> anyhow::Result<()> {
|
||||
// Parse args before any logging starts
|
||||
let args = Args::parse();
|
||||
|
||||
set_up_logging();
|
||||
set_up_logging(args.verbose);
|
||||
info!("You are running {NAME} {VERSION}");
|
||||
|
||||
let state = AppState::new(&args.db).await?;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use sqlx::{
|
|||
sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions, SqliteSynchronous},
|
||||
SqlitePool,
|
||||
};
|
||||
use tracing::{info, debug};
|
||||
|
||||
// TODO Occasionally run PRAGMA optimize
|
||||
async fn pool(db_path: &Path) -> sqlx::Result<SqlitePool> {
|
||||
|
|
@ -25,8 +26,10 @@ async fn pool(db_path: &Path) -> sqlx::Result<SqlitePool> {
|
|||
.create_if_missing(true)
|
||||
.optimize_on_close(true, None);
|
||||
|
||||
info!("Opening db at {}", db_path.display());
|
||||
let pool = SqlitePoolOptions::new().connect_with(options).await?;
|
||||
|
||||
debug!("Applying outstanding db migrations");
|
||||
sqlx::migrate!().run(&pool).await?;
|
||||
|
||||
Ok(pool)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue