From 34def94cd8bb4d8c7cecaf8a26f047ec918b3a7a Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 12 Jan 2023 15:28:02 -0300 Subject: [PATCH] Colorful logs! --- store/Cargo.toml | 2 ++ store/src/main.rs | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/store/Cargo.toml b/store/Cargo.toml index 23fe845..7fd9e3b 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -12,3 +12,5 @@ clap = { version = "4.0.29", features = ["env", "derive", "color"] } dotenv = "0.15.0" sqlx = { version = "0.6.2", features = ["sqlite", "uuid", "chrono", "migrate", "runtime-tokio-rustls"] } tokio = { version = "1.22.0", features = ["macros", "rt"] } +tracing = "0.1.37" +tracing-subscriber = { version = "0.3.16", default-features = false, features = ["env-filter", "fmt", "ansi"] } diff --git a/store/src/main.rs b/store/src/main.rs index 42b3917..95a459a 100644 --- a/store/src/main.rs +++ b/store/src/main.rs @@ -1,16 +1,25 @@ +mod domain; + use clap::Parser; use sqlx::sqlite::SqliteConnectOptions; use sqlx::sqlite::SqlitePoolOptions; +use tracing_subscriber::fmt; +use tracing_subscriber::prelude::*; +use tracing_subscriber::EnvFilter; use crate::domain::options::Options; -mod domain; - #[tokio::main] async fn main() -> Result<(), sqlx::Error> { dotenv::dotenv().ok(); + tracing_subscriber::registry() + .with(fmt::layer()) + .with(EnvFilter::from_default_env()) + .init(); + let options = Options::parse(); + tracing::debug!("Migrating..."); let pool = SqlitePoolOptions::new() .connect_with( SqliteConnectOptions::new() @@ -19,6 +28,6 @@ async fn main() -> Result<(), sqlx::Error> { ) .await?; sqlx::migrate!("./migrations").run(&pool).await?; - print!("Hello world!"); + tracing::debug!("Migration done."); Ok(()) }