From 70c8ff28a1bb9a66cba9463b0fe1cac4b1b4b9bf Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 5 Mar 2024 21:03:37 +0100 Subject: [PATCH] Better logging in new_comment route --- server/src/routes/comment.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/src/routes/comment.rs b/server/src/routes/comment.rs index dcb1afe..e7098f1 100644 --- a/server/src/routes/comment.rs +++ b/server/src/routes/comment.rs @@ -42,7 +42,6 @@ pub async fn new_comment( } let claims = user_claims.unwrap(); - info!("User {:?} created a new comment", &claims.sub); let content = data.content.clone(); let username = claims.sub.clone(); @@ -54,6 +53,13 @@ pub async fn new_comment( .unwrap() .id; + info!( + "User {:?}, with id {:?} is creating a new comment", + &claims.sub, userid + ); + + info!("Creating a new comment {:?}", &data); + let success = db_new_comment( &state.pool, data.parent_post_id, @@ -64,7 +70,13 @@ pub async fn new_comment( .await; match success { - true => Ok(HttpResponse::Ok().json("Success")), - false => Ok(HttpResponse::BadRequest().json("Error")), + true => { + info!("User {:?} created a new comment", &claims.sub); + Ok(HttpResponse::Ok().json("Successfully created comment")) + } + false => { + info!("User {:?} failed to create a new comment", &claims.sub); + Ok(HttpResponse::BadRequest().json("Failed to create comment")) + } } }