Use tracing macros by fully-qualifying them

This commit is contained in:
Thomas Eizinger 2021-03-09 10:23:12 +11:00
parent cc131ecf60
commit 142e5e2d3a
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -8,7 +8,6 @@ use serde_json::Value;
use std::convert::TryFrom;
use tokio::sync::watch;
use tokio_tungstenite::tungstenite;
use tracing::{error, trace};
pub async fn connect() -> Result<RateUpdateStream> {
let (rate_update, rate_update_receiver) = watch::channel(Err(Error::NotYetRetrieved));
@ -24,25 +23,26 @@ pub async fn connect() -> Result<RateUpdateStream> {
Ok(tungstenite::Message::Text(msg)) => msg,
Ok(tungstenite::Message::Close(close_frame)) => {
if let Some(tungstenite::protocol::CloseFrame { code, reason }) = close_frame {
error!(
tracing::error!(
"Kraken rate stream was closed with code {} and reason: {}",
code, reason
code,
reason
);
} else {
error!("Kraken rate stream was closed without code and reason");
tracing::error!("Kraken rate stream was closed without code and reason");
}
let _ = rate_update.send(Err(Error::ConnectionClosed));
continue;
}
Ok(msg) => {
trace!(
tracing::trace!(
"Kraken rate stream returned non text message that will be ignored: {}",
msg
);
continue;
}
Err(e) => {
error!(%e, "Error when reading from Kraken rate stream");
tracing::error!(%e, "Error when reading from Kraken rate stream");
let _ = rate_update.send(Err(e.into()));
continue;
}