Browse Source

Use tracing-subscriber instead of env-logger

drone-volume-cache
Alex Mikhalev 4 years ago
parent
commit
c58ad6b2cc
  1. 8
      Cargo.toml
  2. 11
      src/main.rs

8
Cargo.toml

@ -8,13 +8,15 @@ edition = "2018"
[dependencies] [dependencies]
rusqlite = "0.23.1" rusqlite = "0.23.1"
log = "0.4.11"
env_logger = "0.7.1"
color-eyre = "0.5.1" color-eyre = "0.5.1"
eyre = "0.6.0" eyre = "0.6.0"
thiserror = "1.0.20" thiserror = "1.0.20"
tokio = { version = "0.2.22", features = ["rt-core", "time", "sync", "macros", "test-util"] } tokio = { version = "0.2.22", features = ["rt-core", "time", "sync", "macros", "test-util"] }
tracing = { version = "0.1.19", features = ["log"] } tracing = { version = "0.1.19", features = ["log"] }
tracing-futures = "0.2.4" tracing-futures = "0.2.4"
tracing-subscriber = { version = "0.2.11", features = ["registry"] }
pin-project = "0.4.23" pin-project = "0.4.23"
[dependencies.tracing-subscriber]
version = "0.2.11"
default-features = false
features = ["registry", "fmt", "env-filter", "ansi"]

11
src/main.rs

@ -1,3 +1,5 @@
#![feature(drain_filter)]
use color_eyre::eyre::Result; use color_eyre::eyre::Result;
use rusqlite::Connection as DbConnection; use rusqlite::Connection as DbConnection;
use rusqlite::NO_PARAMS; use rusqlite::NO_PARAMS;
@ -30,8 +32,15 @@ fn query_sections(conn: &DbConnection) -> Result<Vec<Section>> {
} }
fn main() -> Result<()> { fn main() -> Result<()> {
env_logger::init(); tracing_subscriber::fmt()
.with_ansi(true)
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.init();
color_eyre::install()?; color_eyre::install()?;
let conn = setup_db()?; let conn = setup_db()?;
let sections = query_sections(&conn)?; let sections = query_sections(&conn)?;

Loading…
Cancel
Save