From fa13e57835e487d586024a2e065e8f4b30dc88cd Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 2 Oct 2020 18:36:57 -0400 Subject: incorporate tracing instead of log (#222) * incorporate tracing instead of log * fix a test * fix a test --- lib/patreon/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/patreon/src') diff --git a/lib/patreon/src/lib.rs b/lib/patreon/src/lib.rs index 57e2c02..5e37ad7 100644 --- a/lib/patreon/src/lib.rs +++ b/lib/patreon/src/lib.rs @@ -1,6 +1,7 @@ +use chrono::prelude::*; use serde::{Deserialize, Serialize}; use thiserror::Error; -use chrono::prelude::*; +use tracing::{debug, error, instrument}; pub type Campaigns = Vec>; pub type Pledges = Vec>; @@ -70,7 +71,7 @@ pub enum Error { Request(#[from] reqwest::Error), } -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct Credentials { pub client_id: String, pub client_secret: String, @@ -112,6 +113,7 @@ impl Client { } } + #[instrument(skip(self))] pub async fn campaign(&self) -> Result>, ()>> { let data = self .cli @@ -126,11 +128,14 @@ impl Client { ) .send() .await? - .error_for_status()?.text().await?; - log::debug!("campaign response: {}", data); + .error_for_status()? + .text() + .await?; + debug!("campaign response: {}", data); Ok(serde_json::from_str(&data)?) } + #[instrument(skip(self))] pub async fn pledges(&self, camp_id: String) -> Result>> { let data = self .cli @@ -148,8 +153,8 @@ impl Client { .error_for_status()? .text() .await?; - log::debug!("pledges for {}: {}", camp_id, data); - let data : Data>, Object> = serde_json::from_str(&data)?; + debug!("pledges for {}: {}", camp_id, data); + let data: Data>, Object> = serde_json::from_str(&data)?; Ok(data.included.unwrap()) } } -- cgit v1.2.3