From 6ab98389777abe2f9c3402706cded793e59275ff Mon Sep 17 00:00:00 2001 From: Darin Date: Wed, 10 Apr 2019 15:45:13 -0400 Subject: [PATCH] added some error logging for extractors: Data, Json, Query, and Path (#765) * added some error logging for extractors * changed log::error to log::debug and fixed position of log for path * added request path to debug logs --- src/data.rs | 3 +++ src/types/json.rs | 4 ++++ src/types/query.rs | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/data.rs b/src/data.rs index 7fb382f82..edaf32c8e 100644 --- a/src/data.rs +++ b/src/data.rs @@ -96,6 +96,8 @@ impl FromRequest

for Data { if let Some(st) = req.app_config().extensions().get::>() { Ok(st.clone()) } else { + log::debug!("Failed to construct App-level Data extractor. \ + Request path: {:?}", req.path()); Err(ErrorInternalServerError( "App data is not configured, to configure use App::data()", )) @@ -235,6 +237,7 @@ impl FromRequest

for RouteData { if let Some(st) = req.route_data::() { Ok(st.clone()) } else { + log::debug!("Failed to construct Route-level Data extractor"); Err(ErrorInternalServerError( "Route data is not configured, to configure use Route::data()", )) diff --git a/src/types/json.rs b/src/types/json.rs index 912561510..99fd5b417 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -179,10 +179,14 @@ where .map(|c| (c.limit, c.ehandler.clone())) .unwrap_or((32768, None)); + let path = req.path().to_string(); + Box::new( JsonBody::new(req, payload) .limit(limit) .map_err(move |e| { + log::debug!("Failed to deserialize Json from payload. \ + Request path: {:?}", path); if let Some(err) = err { (*err)(e, &req2) } else { diff --git a/src/types/query.rs b/src/types/query.rs index 3bbb465c9..363d56199 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -122,6 +122,10 @@ where fn from_request(req: &HttpRequest, _: &mut Payload

) -> Self::Future { serde_urlencoded::from_str::(req.query_string()) .map(|val| Ok(Query(val))) - .unwrap_or_else(|e| Err(e.into())) + .unwrap_or_else(|e| { + log::debug!("Failed during Query extractor deserialization. \ + Request path: {:?}", req.path()); + Err(e.into()) + }) } }