Replace all event! by a specific macro: warn!, error!, etc.

This commit is contained in:
Greg Burri 2025-04-30 01:50:50 +02:00
parent 1485110204
commit 8152d3d9b0
7 changed files with 43 additions and 82 deletions

View file

@ -17,7 +17,7 @@ use chrono::Duration;
use lettre::Address;
use serde::Deserialize;
use strum_macros::Display;
use tracing::{Level, event};
use tracing::{error, warn};
use crate::{
app::{AppState, Context, Result},
@ -94,11 +94,9 @@ pub async fn sign_up_post(
form_data: &SignUpFormData,
context: Context,
) -> Result<Response> {
event!(
Level::WARN,
warn!(
"Unable to sign up with email {}: {}",
form_data.email,
error
form_data.email, error
);
let invalid_password_mess = &context.tr.tp(
@ -213,8 +211,7 @@ pub async fn sign_up_validation(
) -> Result<(CookieJar, impl IntoResponse)> {
let mut jar = CookieJar::from_headers(&headers);
if let Some(ref user) = context.user {
event!(
Level::WARN,
warn!(
"Unable to validate: user already logged. Email: {}",
user.email
);
@ -261,11 +258,7 @@ pub async fn sign_up_validation(
))
}
db::user::ValidationResult::ValidationExpired => {
event!(
Level::WARN,
"Unable to validate: validation expired. Token: {}",
token
);
warn!("Unable to validate: validation expired. Token: {}", token);
Ok((
jar,
Html(
@ -279,11 +272,7 @@ pub async fn sign_up_validation(
))
}
db::user::ValidationResult::UnknownUser => {
event!(
Level::WARN,
"Unable to validate: unknown user. Token: {}",
token
);
warn!("Unable to validate: unknown user. Token: {}", token);
Ok((
jar,
Html(
@ -299,7 +288,7 @@ pub async fn sign_up_validation(
}
}
None => {
event!(Level::WARN, "Unable to validate: no token provided");
warn!("Unable to validate: no token provided");
Ok((
jar,
Html(
@ -356,11 +345,9 @@ pub async fn sign_in_post(
.await?
{
error @ db::user::SignInResult::AccountNotValidated => {
event!(
Level::WARN,
warn!(
"Account not validated, email: {}: {}",
form_data.email,
error
form_data.email, error
);
Ok((
jar,
@ -376,7 +363,7 @@ pub async fn sign_in_post(
))
}
error @ (db::user::SignInResult::UserNotFound | db::user::SignInResult::WrongPassword) => {
event!(Level::WARN, "Email: {}: {}", form_data.email, error);
warn!("Email: {}: {}", form_data.email, error);
Ok((
jar,
Html(
@ -564,7 +551,7 @@ pub async fn ask_reset_password_post(
}
}
Err(error) => {
event!(Level::ERROR, "{}", error);
error!("{}", error);
error_response(
AskResetPasswordError::DatabaseError,
&form_data.email,
@ -649,8 +636,7 @@ pub async fn reset_password_post(
form_data: &ResetPasswordForm,
context: Context,
) -> Result<Response> {
event!(
Level::WARN,
warn!(
"Email: {}: {}",
if let Some(ref user) = context.user {
&user.email
@ -779,8 +765,7 @@ pub async fn edit_user_post(
form_data: &EditUserForm,
context: Context,
) -> Result<Response> {
event!(
Level::WARN,
warn!(
"Email: {}: {}",
if let Some(ref user) = context.user {
&user.email
@ -978,7 +963,7 @@ pub async fn email_revalidation(
))
}
error @ db::user::ValidationResult::ValidationExpired => {
event!(Level::WARN, "Token: {}: {}", token, error);
warn!("Token: {}: {}", token, error);
Ok((
jar,
Html(
@ -992,7 +977,7 @@ pub async fn email_revalidation(
))
}
error @ db::user::ValidationResult::UnknownUser => {
event!(Level::WARN, "Email: {}: {}", token, error);
warn!("Email: {}: {}", token, error);
Ok((
jar,
Html(