From e45e16456160b31c6506e5c13bc6b2f1dfa795a6 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 10 Jun 2021 01:25:49 -0700 Subject: [PATCH] Improve guard forward and failure logs. --- core/codegen/src/attribute/route/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/codegen/src/attribute/route/mod.rs b/core/codegen/src/attribute/route/mod.rs index c9eae2bb..0b9afa92 100644 --- a/core/codegen/src/attribute/route/mod.rs +++ b/core/codegen/src/attribute/route/mod.rs @@ -100,7 +100,7 @@ fn query_decls(route: &Route) -> Option { )* if !__e.is_empty() { - #_log::warn_!("query string failed to match declared route"); + #_log::warn_!("Query string failed to match route declaration."); for _err in __e { #_log::warn_!("{}", _err); } return #Outcome::Forward(#__data); } @@ -119,11 +119,11 @@ fn request_guard_decl(guard: &Guard) -> TokenStream { let #ident: #ty = match <#ty as #FromRequest>::from_request(#__req).await { #Outcome::Success(__v) => __v, #Outcome::Forward(_) => { - #_log::warn_!("`{}` request guard is forwarding.", stringify!(#ty)); + #_log::warn_!("Request guard `{}` is forwarding.", stringify!(#ty)); return #Outcome::Forward(#__data); }, #Outcome::Failure((__c, __e)) => { - #_log::warn_!("`{}` request guard failed: {:?}.", stringify!(#ty), __e); + #_log::warn_!("Request guard `{}` failed: {:?}.", stringify!(#ty), __e); return #Outcome::Failure(__c); } }; @@ -139,7 +139,7 @@ fn param_guard_decl(guard: &Guard) -> TokenStream { // Returned when a dynamic parameter fails to parse. let parse_error = quote!({ - #_log::warn_!("`{}: {}` param guard parsed forwarding with error {:?}", + #_log::warn_!("Parameter guard `{}: {}` is forwarding: {:?}.", #name, stringify!(#ty), __error); #Outcome::Forward(#__data) @@ -182,11 +182,11 @@ fn data_guard_decl(guard: &Guard) -> TokenStream { let #ident: #ty = match <#ty as #FromData>::from_data(#__req, #__data).await { #Outcome::Success(__d) => __d, #Outcome::Forward(__d) => { - #_log::warn_!("`{}` data guard is forwarding.", stringify!(#ty)); + #_log::warn_!("Data guard `{}` is forwarding.", stringify!(#ty)); return #Outcome::Forward(__d); } #Outcome::Failure((__c, __e)) => { - #_log::warn_!("`{}` data guard failed: {:?}.", stringify!(#ty), __e); + #_log::warn_!("Data guard `{}` failed: {:?}.", stringify!(#ty), __e); return #Outcome::Failure(__c); } };