Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Nov 20, 2024
1 parent 5817a25 commit 01d7ec4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions crates/torii/server/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use tower::ServiceBuilder;
use tower_http::cors::{AllowOrigin, CorsLayer};
use tracing::error;

pub(crate) const LOG_TARGET: &str = "torii::server::proxy";

const DEFAULT_ALLOW_HEADERS: [&str; 13] = [
"accept",
"origin",
Expand Down Expand Up @@ -175,7 +177,7 @@ async fn handle(
return match GRAPHQL_PROXY_CLIENT.call(client_ip, &artifacts_addr, req).await {
Ok(response) => Ok(response),
Err(_error) => {
error!("{:?}", _error);
error!(target: LOG_TARGET, "Artifacts proxy error: {:?}", _error);

Check warning on line 180 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L180

Added line #L180 was not covered by tests
Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
Expand All @@ -196,7 +198,7 @@ async fn handle(
return match GRAPHQL_PROXY_CLIENT.call(client_ip, &graphql_addr, req).await {
Ok(response) => Ok(response),
Err(_error) => {
error!("{:?}", _error);
error!(target: LOG_TARGET, "GraphQL proxy error: {:?}", _error);

Check warning on line 201 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L201

Added line #L201 was not covered by tests
Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
Expand All @@ -218,7 +220,7 @@ async fn handle(
return match GRPC_PROXY_CLIENT.call(client_ip, &grpc_addr, req).await {
Ok(response) => Ok(response),
Err(_error) => {
error!("{:?}", _error);
error!(target: LOG_TARGET, "GRPC proxy error: {:?}", _error);

Check warning on line 223 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L223

Added line #L223 was not covered by tests
Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
Expand Down Expand Up @@ -253,7 +255,7 @@ async fn handle(
.unwrap());

Check warning on line 255 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L252-L255

Added lines #L252 - L255 were not covered by tests
};

// Execute the query in a read-only transaction
// Execute the query
return match sqlx::query(&query).fetch_all(&*pool).await {
Ok(rows) => {
let result: Vec<_> = rows
Expand Down Expand Up @@ -302,13 +304,10 @@ async fn handle(
.body(Body::from(json))
.unwrap())

Check warning on line 305 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L295-L305

Added lines #L295 - L305 were not covered by tests
}
Err(e) => {
error!("SQL query error: {:?}", e);
Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Query error"))
.unwrap())
}
Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Query error: {:?}", e)))
.unwrap()),

Check warning on line 310 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L307-L310

Added lines #L307 - L310 were not covered by tests
};
}

Check warning on line 313 in crates/torii/server/src/proxy.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/proxy.rs#L312-L313

Added lines #L312 - L313 were not covered by tests
Expand Down

0 comments on commit 01d7ec4

Please sign in to comment.