Browse Source

Colorful logs!

main
Julio Biason 2 years ago
parent
commit
34def94cd8
  1. 2
      store/Cargo.toml
  2. 15
      store/src/main.rs

2
store/Cargo.toml

@ -12,3 +12,5 @@ clap = { version = "4.0.29", features = ["env", "derive", "color"] }
dotenv = "0.15.0" dotenv = "0.15.0"
sqlx = { version = "0.6.2", features = ["sqlite", "uuid", "chrono", "migrate", "runtime-tokio-rustls"] } sqlx = { version = "0.6.2", features = ["sqlite", "uuid", "chrono", "migrate", "runtime-tokio-rustls"] }
tokio = { version = "1.22.0", features = ["macros", "rt"] } 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"] }

15
store/src/main.rs

@ -1,16 +1,25 @@
mod domain;
use clap::Parser; use clap::Parser;
use sqlx::sqlite::SqliteConnectOptions; use sqlx::sqlite::SqliteConnectOptions;
use sqlx::sqlite::SqlitePoolOptions; use sqlx::sqlite::SqlitePoolOptions;
use tracing_subscriber::fmt;
use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
use crate::domain::options::Options; use crate::domain::options::Options;
mod domain;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), sqlx::Error> { async fn main() -> Result<(), sqlx::Error> {
dotenv::dotenv().ok(); dotenv::dotenv().ok();
tracing_subscriber::registry()
.with(fmt::layer())
.with(EnvFilter::from_default_env())
.init();
let options = Options::parse(); let options = Options::parse();
tracing::debug!("Migrating...");
let pool = SqlitePoolOptions::new() let pool = SqlitePoolOptions::new()
.connect_with( .connect_with(
SqliteConnectOptions::new() SqliteConnectOptions::new()
@ -19,6 +28,6 @@ async fn main() -> Result<(), sqlx::Error> {
) )
.await?; .await?;
sqlx::migrate!("./migrations").run(&pool).await?; sqlx::migrate!("./migrations").run(&pool).await?;
print!("Hello world!"); tracing::debug!("Migration done.");
Ok(()) Ok(())
} }

Loading…
Cancel
Save