Skip to content

Commit

Permalink
Add tracing logging for sucessful calls
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspustina committed Nov 7, 2020
1 parent 83fc3cb commit 227dc6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ edition = "2018"

[dependencies]
failure = "0.1"
log = "0.4.*"
reqwest = { version = "^0.9", features = ["rustls-tls"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"

[dev-dependencies]
env_logger = { version = "0.7.*" }
spectral = "0.6.0"

2 changes: 2 additions & 0 deletions examples/get_station_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use netatmo_rs::{ClientCredentials, Netatmo, NetatmoClient, Scope};
use std::env;

fn main() {
env_logger::init();

let client_id = env::var_os("NETATMO_CLIENT_ID")
.expect("Environment variable 'NETATMO_CLIENT_ID' is not set.")
.to_string_lossy()
Expand Down
2 changes: 2 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use failure::Fail;
use log::trace;
use reqwest::{Response, StatusCode};
use serde::de::DeserializeOwned;
use serde::Deserialize;
Expand Down Expand Up @@ -108,6 +109,7 @@ where
.general_err_handler(name, StatusCode::OK)?;

let body = res.text().map_err(|e| e.context(ErrorKind::FailedToReadResponse))?;
trace!("Sucessful ({:?}) repsone: '{}'", res.status(), body);
serde_json::from_str::<T>(&body).map_err(|e| e.context(ErrorKind::JsonDeserializationFailed).into())
}

Expand Down

0 comments on commit 227dc6a

Please sign in to comment.