Make SQLx logging debug level and add tower-http traces
All checks were successful
Build and Publish Docker Container / build (push) Successful in 10m20s
All checks were successful
Build and Publish Docker Container / build (push) Successful in 10m20s
This commit is contained in:
parent
62d5ad8dc2
commit
89d0d12e26
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -1761,6 +1761,7 @@ dependencies = [
|
|||||||
"testcontainers-modules",
|
"testcontainers-modules",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tower-http",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
@ -3508,6 +3509,23 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tower-http"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.5.0",
|
||||||
|
"bytes",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"http-body-util",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tower-layer",
|
||||||
|
"tower-service",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tower-layer"
|
name = "tower-layer"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
|
|||||||
@ -29,6 +29,7 @@ clap = "4.5.4"
|
|||||||
testcontainers = "0.17.0"
|
testcontainers = "0.17.0"
|
||||||
testcontainers-modules = { version = "0.5.0", features = ["postgres"] }
|
testcontainers-modules = { version = "0.5.0", features = ["postgres"] }
|
||||||
sqlx = { version = "0.7.4", features = ["postgres"] }
|
sqlx = { version = "0.7.4", features = ["postgres"] }
|
||||||
|
tower-http = { version = "0.5.2", features = ["trace"] }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [".", "migration", "entity"]
|
members = [".", "migration", "entity"]
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@ -9,6 +9,8 @@ use clap::Parser;
|
|||||||
use migration::{Migrator, MigratorTrait};
|
use migration::{Migrator, MigratorTrait};
|
||||||
use sea_orm::{ConnectionTrait, DatabaseConnection};
|
use sea_orm::{ConnectionTrait, DatabaseConnection};
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
use tower_http::trace::TraceLayer;
|
||||||
|
use tracing::log::LevelFilter;
|
||||||
|
|
||||||
#[derive(Debug, clap::Parser)]
|
#[derive(Debug, clap::Parser)]
|
||||||
struct Config {
|
struct Config {
|
||||||
@ -36,7 +38,11 @@ async fn health_check(
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let config: Config = Config::parse();
|
let config: Config = Config::parse();
|
||||||
let connection = sea_orm::Database::connect(&config.database_url).await?;
|
let connection = sea_orm::ConnectOptions::new(&config.database_url)
|
||||||
|
.sqlx_logging_level(LevelFilter::Debug)
|
||||||
|
.to_owned();
|
||||||
|
|
||||||
|
let connection = sea_orm::Database::connect(connection).await?;
|
||||||
|
|
||||||
if config.migrate {
|
if config.migrate {
|
||||||
Migrator::up(&connection, None).await?;
|
Migrator::up(&connection, None).await?;
|
||||||
@ -48,7 +54,8 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.route("/monzo-updated", post(monzo_updated))
|
.route("/monzo-updated", post(monzo_updated))
|
||||||
.route("/monzo-batch-export", post(monzo_batched_json))
|
.route("/monzo-batch-export", post(monzo_batched_json))
|
||||||
.route("/monzo-csv-ingestion", post(monzo_batched_csv))
|
.route("/monzo-csv-ingestion", post(monzo_batched_csv))
|
||||||
.layer(Extension(connection.clone()));
|
.layer(Extension(connection.clone()))
|
||||||
|
.layer(TraceLayer::new_for_http());
|
||||||
|
|
||||||
tracing::debug!("listening on {}", &config.addr);
|
tracing::debug!("listening on {}", &config.addr);
|
||||||
let listener = tokio::net::TcpListener::bind(&config.addr).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(&config.addr).await.unwrap();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user