Skip to content

Commit

Permalink
Identify logs we write in outside modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
hcldan committed Jun 6, 2024
1 parent 6a28edd commit 7a3375d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/codegen/src/attribute/route/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,22 @@ fn request_guard_decl(guard: &Guard) -> TokenStream {
define_spanned_export!(ty.span() =>
__req, __data, _request, display_hack, FromRequest, Outcome
);

let path = module_path!();

quote_spanned! { ty.span() =>
let #ident: #ty = match <#ty as #FromRequest>::from_request(#__req).await {
#Outcome::Success(__v) => __v,
#Outcome::Forward(__e) => {
::rocket::trace::info!(name: "forward", parameter = stringify!(#ident),
::rocket::trace::info!(name: "forward", target: &#path, parameter = stringify!(#ident),
type_name = stringify!(#ty), status = __e.code,
"request guard forwarding");

return #Outcome::Forward((#__data, __e));
},
#[allow(unreachable_code)]
#Outcome::Error((__c, __e)) => {
::rocket::trace::info!(name: "failure", parameter = stringify!(#ident),
::rocket::trace::info!(name: "failure", target: &#path, parameter = stringify!(#ident),
type_name = stringify!(#ty), reason = %#display_hack!(__e),
"request guard failed");

Expand Down Expand Up @@ -369,8 +371,9 @@ fn codegen_route(route: Route) -> Result<TokenStream> {
let format = Optional(route.attr.format.as_ref());

Ok(quote! {

#handler_fn

#[doc(hidden)]
#[allow(nonstandard_style)]
/// Rocket code generated proxy structure.
Expand Down

0 comments on commit 7a3375d

Please sign in to comment.