Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
Switch from SQLx logging to SeaORM logging which is clearer.
  • Loading branch information
Aleksbgbg committed Feb 19, 2024
1 parent 602da88 commit 60ee891
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend-rs/streamfox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fs-file = { version = "0.0.0", path = "../fs-file", default-features = false }
jsonwebtoken = { version = "9.2.0", default-features = false }
lazy_static = "1.4.0"
ring = "0.17.7"
sea-orm = { version = "0.12.14", features = ["runtime-tokio-rustls", "sqlx-postgres"] }
sea-orm = { version = "0.12.14", features = ["runtime-tokio-rustls", "sqlx-postgres", "debug-print"] }
sea-orm-migration = "0.12.12"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
Expand Down
12 changes: 8 additions & 4 deletions backend-rs/streamfox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::snowflake::SnowflakeGenerator;
use axum::{routing, Router};
use cascade::cascade;
use fs::filesystem;
use sea_orm::{Database, DatabaseConnection, DbErr};
use sea_orm::{ConnectOptions, Database, DatabaseConnection, DbErr};
use sea_orm_migration::MigratorTrait;
use std::io;
use std::net::SocketAddr;
Expand Down Expand Up @@ -70,11 +70,15 @@ async fn main() -> Result<(), AppError> {
tracing_subscriber::fmt()
.with_target(false)
.compact()
.with_max_level(tracing::Level::DEBUG)
.init();

let connection = Database::connect(&config.database.connection_string())
.await
.map_err(AppError::ConnectToDatabase)?;
let connection = Database::connect(cascade! {
ConnectOptions::new(config.database.connection_string());
..sqlx_logging(false);
})
.await
.map_err(AppError::ConnectToDatabase)?;
Migrator::up(&connection, None)
.await
.map_err(AppError::MigrateDatabase)?;
Expand Down

0 comments on commit 60ee891

Please sign in to comment.