Skip to content

Commit

Permalink
Update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
arturofigueroabim committed Nov 25, 2024
1 parent 491bc6f commit 2fa04fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use futures_util::StreamExt;
use reqwest::{header, Method};
use serde_json::json;
use tracing::warn;
use tracing::{debug, info, error};
use tracing::{debug, info};
use uuid::Uuid;

pub async fn send_token_registration_request(
Expand Down Expand Up @@ -230,7 +230,7 @@ pub async fn check_project_status_request(
}) => {
let status = StatusCode::from_u16(status_code as u16)
.unwrap_or(StatusCode::INTERNAL_SERVER_ERROR);
warn!("Received status response for project. Project ID: {}, BK: {}, Status: {}, Response: {}",
debug!("Received status response for project. Project ID: {}, BK: {}, Status: {}, Response: {}",
query_params.project_id,
query_params.bk,
status,
Expand Down Expand Up @@ -356,7 +356,7 @@ async fn save_tokens_from_beam(
Ok(v) => v,
Err(e) => {
let error_msg = format!("Failed to deserialize message {msg:?} into a result: {e}");
warn!("{error_msg}");
debug!("{error_msg}");
last_error = Some(error_msg);
continue;
}
Expand Down Expand Up @@ -434,7 +434,7 @@ async fn update_tokens_from_beam(
Ok(v) => v,
Err(e) => {
let error_msg = format!("Failed to deserialize message {msg:?} into a result: {e}");
warn!("{error_msg}");
debug!("{error_msg}");
last_error = Some(error_msg);
continue;
}
Expand Down Expand Up @@ -506,7 +506,7 @@ async fn status_from_beam(
Ok(v) => v,
Err(e) => {
let error_msg = format!("Failed to deserialize message {msg:?} into a result: {e}");
warn!("{error_msg}");
debug!("{error_msg}");
last_error = Some(error_msg);
continue;
}
Expand Down Expand Up @@ -570,7 +570,7 @@ async fn fetch_project_tables_from_beam(
Ok(v) => v,
Err(e) => {
let error_msg = format!("Failed to deserialize message {msg:?} into a result: {e}");
warn!("{error_msg}");
debug!("{error_msg}");
continue;
}
};
Expand Down Expand Up @@ -629,7 +629,7 @@ async fn remove_project_and_tokens_from_beam(
Ok(v) => v,
Err(e) => {
let error_msg = format!("Failed to deserialize message {msg:?} into a result: {e}");
warn!("{error_msg}");
debug!("{error_msg}");
last_error = Some(error_msg);
continue;
}
Expand Down Expand Up @@ -690,7 +690,7 @@ async fn remove_tokens_from_beam(
Ok(v) => v,
Err(e) => {
let error_msg = format!("Failed to deserialize message {msg:?} into a result: {e}");
warn!("{error_msg}");
debug!("{error_msg}");
last_error = Some(error_msg);
continue;
}
Expand Down
16 changes: 8 additions & 8 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use axum::{
Json, Router,
};
use serde_json::json;
use tracing::{error, warn};
use tracing::debug;

async fn create_token(db: Db, token_params: Json<TokenParams>) -> impl IntoResponse {
if let Err(e) = send_token_registration_request(db, token_params.0).await {
error!("Unhandled error: {e:?}");
debug!("Unhandled error: {e:?}");
StatusCode::INTERNAL_SERVER_ERROR
} else {
StatusCode::OK
Expand Down Expand Up @@ -52,15 +52,15 @@ async fn generate_script(mut db: Db, script_params: Json<TokenParams>) -> impl I
match db.generate_user_script(script_params.0).await {
Ok(script) => (StatusCode::OK, script).into_response(),
Err(e) => {
warn!("Error generating script: {e}");
debug!("Error generating script: {e}");
StatusCode::INTERNAL_SERVER_ERROR.into_response()
}
}
}

async fn refresh_token(db: Db, token_params: Json<TokenParams>) -> StatusCode {
if let Err(e) = refresh_token_request(db, token_params.0).await {
error!("Unhandled error: {e:?}");
debug!("Unhandled error: {e:?}");
StatusCode::INTERNAL_SERVER_ERROR
} else {
StatusCode::OK
Expand All @@ -74,7 +74,7 @@ async fn remove_project_and_token(db: Db, query: Query<ProjectQueryParams>) -> i
status_code,
error_message,
}) => {
warn!(
debug!(
?query,
?error_message,
?status_code,
Expand All @@ -85,7 +85,7 @@ async fn remove_project_and_token(db: Db, query: Query<ProjectQueryParams>) -> i
(status, Json(json!({ "error": error_message }))).into_response()
}
Err(e) => {
error!("Unhandled error: {e:?}");
debug!("Unhandled error: {e:?}");
StatusCode::INTERNAL_SERVER_ERROR.into_response()
}
}
Expand All @@ -98,7 +98,7 @@ async fn remove_tokens(db: Db, query: Query<TokensQueryParams>) -> impl IntoResp
status_code,
error_message,
}) => {
warn!(
debug!(
?query,
?error_message,
?status_code,
Expand All @@ -109,7 +109,7 @@ async fn remove_tokens(db: Db, query: Query<TokensQueryParams>) -> impl IntoResp
(status, Json(json!({ "error": error_message }))).into_response()
}
Err(e) => {
error!("Unhandled error: {e:?}");
debug!("Unhandled error: {e:?}");
StatusCode::INTERNAL_SERVER_ERROR.into_response()
}
}
Expand Down

0 comments on commit 2fa04fd

Please sign in to comment.