diff options
Diffstat (limited to 'src/macros.rs')
-rw-r--r-- | src/macros.rs | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/macros.rs b/src/macros.rs index f4eb274..1bbb7bd 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -18,10 +18,10 @@ macro_rules! methods { async fn $method_with_call_id<T: for<'de> serde::Deserialize<'de> + serde::Serialize>(&self, url: impl AsRef<str>, call_id: Uuid) -> Result<T> { - use log::{debug, as_debug}; + use log::debug; let url = url.as_ref(); - debug!(url = url, method = stringify!($method), call_id = as_debug!(call_id); "making API request"); + debug!(url = url, method = stringify!($method), call_id:? = call_id; "making API request"); let response = self.authenticated(self.client.$method(url)).header("Accept", "application/json").send().await?; read_response(response).await } @@ -47,10 +47,10 @@ macro_rules! paged_routes { "```" ), pub async fn $name(&self) -> Result<Page<$ret>> { - use log::{debug, as_debug}; + use log::debug; let url = self.route(concat!("/api/v1/", $url)); let call_id = uuid::Uuid::new_v4(); - debug!(url = url, method = stringify!($method), call_id = as_debug!(call_id); "making API request"); + debug!(url = url, method = stringify!($method), call_id:? = call_id; "making API request"); let response = self.authenticated(self.client.$method(&url)).header("Accept", "application/json").send().await?; Page::new(self.clone(), response, call_id).await @@ -70,7 +70,7 @@ macro_rules! paged_routes { ), pub async fn $name<'a>(&self, $($param: $typ,)*) -> Result<Page<$ret>> { use serde_urlencoded; - use log::{debug, as_debug}; + use log::debug; let call_id = uuid::Uuid::new_v4(); @@ -99,7 +99,7 @@ macro_rules! paged_routes { let url = format!(concat!("/api/v1/", $url, "?{}"), &qs); let url = self.route(url); - debug!(url = url, method = "get", call_id = as_debug!(call_id); "making API request"); + debug!(url = url, method = "get", call_id:? = call_id; "making API request"); let response = self.authenticated(self.client.get(&url)).header("Accept", "application/json").send().await?; @@ -123,7 +123,7 @@ macro_rules! route_v2 { ), pub async fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> { use serde_urlencoded; - use log::{debug, as_serde}; + use log::debug; use uuid::Uuid; let call_id = Uuid::new_v4(); @@ -147,7 +147,7 @@ macro_rules! route_v2 { let qs = serde_urlencoded::to_string(&qs_data)?; - debug!(query_string_data = as_serde!(qs_data); "URL-encoded data to be sent in API request"); + debug!(query_string_data:serde = qs_data; "URL-encoded data to be sent in API request"); let url = format!(concat!("/api/v2/", $url, "?{}"), &qs); @@ -167,7 +167,7 @@ macro_rules! route_v2 { "\n# Errors\nIf `access_token` is not set."), pub async fn $name(&self $(, $param: $typ)*, description: Option<String>) -> Result<$ret> { use reqwest::multipart::Form; - use log::{debug, as_debug}; + use log::debug; use uuid::Uuid; let call_id = Uuid::new_v4(); @@ -185,7 +185,7 @@ macro_rules! route_v2 { debug!( url = url, method = stringify!($method), - multipart_form_data = as_debug!(form_data), call_id = as_debug!(call_id); + multipart_form_data:? = form_data, call_id:? = call_id; "making API request" ); @@ -210,7 +210,7 @@ macro_rules! route_v2 { "`\n# Errors\nIf `access_token` is not set."), pub async fn $name(&self, $($param: $typ,)*) -> Result<$ret> { use reqwest::multipart::Form; - use log::{debug, as_debug}; + use log::debug; use uuid::Uuid; @@ -225,7 +225,7 @@ macro_rules! route_v2 { debug!( url = url, method = stringify!($method), - multipart_form_data = as_debug!(form_data), call_id = as_debug!(call_id); + multipart_form_data:? = form_data, call_id:? = call_id; "making API request" ); @@ -254,7 +254,7 @@ macro_rules! route { "`\n# Errors\nIf `access_token` is not set."), pub async fn $name(&self, $($param: $typ,)*) -> Result<$ret> { use reqwest::multipart::Form; - use log::{debug, as_debug}; + use log::debug; use uuid::Uuid; @@ -269,7 +269,7 @@ macro_rules! route { debug!( url = url, method = stringify!($method), - multipart_form_data = as_debug!(form_data), call_id = as_debug!(call_id); + multipart_form_data:? = form_data, call_id:? = call_id; "making API request" ); @@ -295,7 +295,7 @@ macro_rules! route { "\n# Errors\nIf `access_token` is not set."), pub async fn $name(&self $(, $param: $typ)*, description: Option<String>) -> Result<$ret> { use reqwest::multipart::Form; - use log::{debug, as_debug}; + use log::debug; use uuid::Uuid; @@ -314,7 +314,7 @@ macro_rules! route { debug!( url = url, method = stringify!($method), - multipart_form_data = as_debug!(form_data), call_id = as_debug!(call_id); + multipart_form_data:? = form_data, call_id:? = call_id; "making API request" ); @@ -338,7 +338,7 @@ macro_rules! route { ), pub async fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> { use serde_urlencoded; - use log::{debug, as_serde}; + use log::debug; use uuid::Uuid; let call_id = Uuid::new_v4(); @@ -363,7 +363,7 @@ macro_rules! route { let qs = serde_urlencoded::to_string(&qs_data)?; - debug!(query_string_data = as_serde!(qs_data); "URL-encoded data to be sent in API request"); + debug!(query_string_data:serde = qs_data; "URL-encoded data to be sent in API request"); let url = format!(concat!("/api/v1/", $url, "?{}"), &qs); @@ -382,7 +382,7 @@ macro_rules! route { "`\n# Errors\nIf `access_token` is not set.", ), pub async fn $name(&self, $($param: $typ,)*) -> Result<$ret> { - use log::{debug, as_debug, as_serde}; + use log::debug; use uuid::Uuid; let call_id = Uuid::new_v4(); @@ -395,8 +395,8 @@ macro_rules! route { let url = &self.route(concat!("/api/v1/", $url)); debug!( url = url.as_str(), method = stringify!($method), - call_id = as_debug!(call_id), - form_data = as_serde!(&form_data); + call_id:? = call_id, + form_data:serde = &form_data; "making API request" ); @@ -482,13 +482,13 @@ macro_rules! paged_routes_with_id { "```" ), pub async fn $name(&self, id: impl AsRef<str>) -> Result<Page<$ret>> { - use log::{debug, as_debug}; + use log::debug; use uuid::Uuid; let call_id = Uuid::new_v4(); let url = self.route(&format!(concat!("/api/v1/", $url), id.as_ref())); - debug!(url = url, method = stringify!($method), call_id = as_debug!(call_id); "making API request"); + debug!(url = url, method = stringify!($method), call_id:? = call_id; "making API request"); let response = self.authenticated(self.client.$method(&url)).header("Accept", "application/json").send().await?; Page::new(self.clone(), response, call_id).await } @@ -533,8 +533,8 @@ tokio_test::block_on(async { let url = self.route(&format!("/api/v1/streaming/{}", $stream)); let response = self.authenticated(self.client.get(&url)).header("Accept", "application/json").send().await?; debug!( - status = log_serde!(response Status), url = &url, - headers = log_serde!(response Headers); + status:serde = crate::helpers::log::Status::from(&response), url = &url, + headers:serde = crate::helpers::log::Headers::from(&response); "received API response" ); let status = response.status(); @@ -584,8 +584,8 @@ tokio_test::block_on(async { let url = url.to_string(); let response = self.authenticated(self.client.get(url.as_str())).header("Accept", "application/json").send().await?; debug!( - status = log_serde!(response Status), url = as_debug!(url), - headers = log_serde!(response Headers); + status:serde = crate::helpers::log::Status::from(&response), url:? = url, + headers:serde = crate::helpers::log::Headers::from(&response); "received API response" ); let status = response.status(); @@ -635,8 +635,8 @@ tokio_test::block_on(async { let url = url.to_string(); let response = self.authenticated(self.client.get(url.as_str())).header("Accept", "application/json").send().await?; debug!( - status = log_serde!(response Status), url = as_debug!(url), - headers = log_serde!(response Headers); + status:serde = crate::helpers::log::Status::from(&response), url:? = url, + headers:serde = crate::helpers::log::Headers::from(&response); "received API response" ); let status = response.status(); |