From c58ad6b2ccb7151b25fc0cfd59f60dae557d5df1 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Mon, 17 Aug 2020 19:58:58 -0600 Subject: [PATCH] Use tracing-subscriber instead of env-logger --- Cargo.toml | 8 +++++--- src/main.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1234682..67e5687 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,13 +8,15 @@ edition = "2018" [dependencies] rusqlite = "0.23.1" -log = "0.4.11" -env_logger = "0.7.1" color-eyre = "0.5.1" eyre = "0.6.0" thiserror = "1.0.20" tokio = { version = "0.2.22", features = ["rt-core", "time", "sync", "macros", "test-util"] } tracing = { version = "0.1.19", features = ["log"] } tracing-futures = "0.2.4" -tracing-subscriber = { version = "0.2.11", features = ["registry"] } pin-project = "0.4.23" + +[dependencies.tracing-subscriber] +version = "0.2.11" +default-features = false +features = ["registry", "fmt", "env-filter", "ansi"] diff --git a/src/main.rs b/src/main.rs index c22215c..364610b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(drain_filter)] + use color_eyre::eyre::Result; use rusqlite::Connection as DbConnection; use rusqlite::NO_PARAMS; @@ -30,8 +32,15 @@ fn query_sections(conn: &DbConnection) -> 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()?; + let conn = setup_db()?; let sections = query_sections(&conn)?;