Skip to content

Commit

Permalink
feat: Replace log with trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Frixxie committed Oct 31, 2024
1 parent e661f96 commit f407a05
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 53 deletions.
118 changes: 83 additions & 35 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ edition = "2021"
anyhow = "1.0.91"
axum = { version = "0.7.7", features = ["macros"] }
chrono = { version = "0.4.38", features = ["serde"] }
log = "0.4.22"
rust-s3 = "0.35.1"
serde = { version = "1.0.213", features = ["derive"] }
sha256 = "1.5.0"
simple_logger = "5.0.0"
sqlx = { version = "0.8.2", features = ["chrono", "postgres", "runtime-tokio"] }
structopt = "0.3.26"
tokio = { version = "1.41.0", features = ["full"] }
tokio = { version = "1.41.0", features = ["full", "tracing"] }
tower = { version = "0.5.1", features = ["tokio", "tracing"] }
tower-http = { version = "0.5.2", features = ["trace"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["json"] }

[dev-dependencies]
reqwest = { version = "0.12.8", features = ["native-tls", "json"] }
Expand Down
19 changes: 10 additions & 9 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
mod category;
mod error;
mod file;
mod item;
mod location;
mod file;
mod category;
mod router;

use std::str::FromStr;

use anyhow::Result;
use log::info;
use simple_logger::SimpleLogger;
use sqlx::PgPool;
use structopt::StructOpt;
use tracing::{info, Level};
use tracing_subscriber::FmtSubscriber;

#[derive(Debug, Clone, StructOpt)]
pub struct Opts {
Expand All @@ -33,9 +31,12 @@ pub struct Opts {
#[tokio::main]
async fn main() -> Result<()> {
let opts = Opts::from_args();
SimpleLogger::new()
.with_level(log::LevelFilter::from_str(&opts.log_level)?)
.init()?;
let subscriber = FmtSubscriber::builder()
.with_max_level(Level::INFO)
.json()
.finish();

tracing::subscriber::set_global_default(subscriber).unwrap();

info!("Connecting to DB at {}", opts.db_url);
let connection = PgPool::connect(&opts.db_url).await.unwrap();
Expand Down
Loading

0 comments on commit f407a05

Please sign in to comment.