diff --git a/Cargo.lock b/Cargo.lock index 58753ad..ac4c0ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,16 +260,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "log", -] - [[package]] name = "errno" version = "0.3.0" @@ -354,12 +344,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "indexmap" version = "1.9.3" @@ -472,10 +456,8 @@ dependencies = [ "dns_common", "dns_common_derive", "edit", - "env_logger", "etcetera", "lazy_static", - "log", "regex", "remove_dir_all 0.8.2", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0115aca..a9dc3d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,6 @@ serde_yaml = "0.9.21" dns_common_derive = { version = "0.2.1" } dns_common = { version = "0.2.1", default-features = false, features = ["yaml", "json"] } unicode-width = "0.1.10" -log = "0.4" -env_logger = { version = "0.10", default_features = false, features = ["humantime"] } [lib] name = "navi" diff --git a/src/bin/main.rs b/src/bin/main.rs index 48c2fa0..a9b90b0 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -1,5 +1,6 @@ extern crate navi; +use dns_common::prelude::{debug, error, tracing, tracing_subscriber}; use thiserror::Error; #[derive(Error, Debug)] @@ -26,16 +27,20 @@ impl FileAnIssue { fn main() -> Result<(), anyhow::Error> { init_logger()?; navi::handle().map_err(|e| { - log::error!("{e:?}"); + error!("{e:?}"); FileAnIssue::new(e).into() }) } fn init_logger() -> anyhow::Result<()> { - let file = std::fs::File::create("navi.log")?; - env_logger::builder() - .target(env_logger::Target::Pipe(Box::new(file))) - .init(); - + tracing::subscriber::set_global_default( + tracing_subscriber::fmt() + .with_ansi(false) + // TODO: config_path/navi.log + .with_writer(std::fs::File::create("navi.log")?) + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .finish(), + )?; + debug!("tracing initialized"); Ok(()) } diff --git a/src/commands/core/mod.rs b/src/commands/core/mod.rs index 2a3d334..8055125 100644 --- a/src/commands/core/mod.rs +++ b/src/commands/core/mod.rs @@ -45,7 +45,7 @@ pub fn init(fetcher: Box) -> Result<()> { pub fn get_fetcher() -> Result> { let source = CONFIG.source(); - log::debug!("{source:#?}"); + debug!("{source:#?}"); match source { Source::Cheats(query) => { let lines = cheatsh::call(&query)?; diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 257df1c..4537177 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -12,7 +12,7 @@ use crate::prelude::*; pub fn handle() -> Result<()> { use crate::config::Command::*; - log::debug!("CONFIG = {:#?}", &*CONFIG); + debug!("CONFIG = {:#?}", &*CONFIG); match CONFIG.cmd() { None => commands::core::main(), diff --git a/src/filesystem.rs b/src/filesystem.rs index ed0f32e..fe4df97 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -181,7 +181,7 @@ impl fetcher::Fetcher for Fetcher { } } - log::debug!("filesystem::Fetcher = {self:#?}"); + debug!("filesystem::Fetcher = {self:#?}"); Ok(found_something) }