use full qualified name for log statements

This commit is contained in:
Rohan Sircar 2021-05-09 00:16:13 +05:30
parent 87dc7547b8
commit d3a3b1e1f2
5 changed files with 8 additions and 10 deletions

View File

@ -44,7 +44,7 @@ impl ResponseError for DomainError {
}) })
} }
DomainError::DbError { source: _ } => { DomainError::DbError { source: _ } => {
error!("{}", err); log::error!("{}", err);
HttpResponse::InternalServerError().json(ErrorModel { HttpResponse::InternalServerError().json(ErrorModel {
// error_code: 500, // error_code: 500,
success: false, success: false,
@ -52,7 +52,7 @@ impl ResponseError for DomainError {
}) })
} }
DomainError::DbPoolError { source: _ } => { DomainError::DbPoolError { source: _ } => {
error!("{}", err); log::error!("{}", err);
HttpResponse::InternalServerError().json(ErrorModel { HttpResponse::InternalServerError().json(ErrorModel {
// error_code: 500, // error_code: 500,
success: false, success: false,
@ -74,7 +74,7 @@ impl ResponseError for DomainError {
}) })
} }
DomainError::ThreadPoolError { message: _ } => { DomainError::ThreadPoolError { message: _ } => {
error!("{}", err); log::error!("{}", err);
HttpResponse::InternalServerError().json(ErrorModel { HttpResponse::InternalServerError().json(ErrorModel {
// error_code: 400, // error_code: 400,
success: false, success: false,

View File

@ -3,8 +3,6 @@
extern crate diesel; extern crate diesel;
#[macro_use] #[macro_use]
extern crate derive_new; extern crate derive_new;
#[macro_use]
extern crate log;
mod actions; mod actions;
mod errors; mod errors;
@ -99,7 +97,7 @@ pub fn app_logger() -> Logger {
pub async fn run(addr: String, app_data: AppData) -> io::Result<()> { pub async fn run(addr: String, app_data: AppData) -> io::Result<()> {
let bi = get_build_info(); let bi = get_build_info();
info!("Starting {} {}", bi.crate_info.name, bi.crate_info.version); log::info!("Starting {} {}", bi.crate_info.name, bi.crate_info.version);
println!( println!(
r#" r#"
__ .__ .___ __ .__ .___

View File

@ -45,7 +45,7 @@ pub async fn logout(
) -> Result<HttpResponse, Error> { ) -> Result<HttpResponse, Error> {
let maybe_identity = id.identity(); let maybe_identity = id.identity();
let response = if let Some(identity) = maybe_identity { let response = if let Some(identity) = maybe_identity {
info!("Logging out {user}", user = identity); log::info!("Logging out {user}", user = identity);
id.forget(); id.forget();
HttpResponse::Found().header("location", "/").finish() HttpResponse::Found().header("location", "/").finish()
} else { } else {

View File

@ -61,7 +61,7 @@ pub async fn get_all_users(
.await .await
.map_err(|err| DomainError::new_thread_pool_error(err.to_string()))?; .map_err(|err| DomainError::new_thread_pool_error(err.to_string()))?;
debug!("{:?}", users); log::debug!("{:?}", users);
if !users.is_empty() { if !users.is_empty() {
Ok(HttpResponse::Ok().json(users)) Ok(HttpResponse::Ok().json(users))
@ -87,7 +87,7 @@ pub async fn add_user(
}) })
.await .await
.map(|user| { .map(|user| {
debug!("{:?}", user); log::debug!("{:?}", user);
HttpResponse::Created().json(user) HttpResponse::Created().json(user)
}), }),

View File

@ -6,7 +6,7 @@ pub trait LogErrorResult<T, E> {
impl<T, E: Display> LogErrorResult<T, E> for Result<T, E> { impl<T, E: Display> LogErrorResult<T, E> for Result<T, E> {
fn log_err(self) -> Result<T, E> { fn log_err(self) -> Result<T, E> {
self.map_err(|err| { self.map_err(|err| {
error!("{}", err.to_string()); log::error!("{}", err.to_string());
err err
}) })
} }