diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs index 08d2d3a8..667c9062 100755 --- a/azalea-auth/src/auth.rs +++ b/azalea-auth/src/auth.rs @@ -10,6 +10,7 @@ use std::{ time::{Instant, SystemTime, UNIX_EPOCH}, }; use thiserror::Error; +use tracing::{error, trace}; use uuid::Uuid; #[derive(Default)] @@ -92,7 +93,7 @@ pub async fn auth<'a>(email: &str, opts: AuthOpts<'a>) -> Result(email: &str, opts: AuthOpts<'a>) -> Result msa = new_msa, Err(e) => { // can't refresh, ask the user to auth again - tracing::error!("Error refreshing Microsoft auth token: {}", e); + error!("Error refreshing Microsoft auth token: {}", e); msa = interactive_get_ms_auth_token(&client, email, Some(client_id), Some(scope)) .await?; @@ -113,7 +114,7 @@ pub async fn auth<'a>(email: &str, opts: AuthOpts<'a>) -> Result(email: &str, opts: AuthOpts<'a>) -> Result() .await { - tracing::trace!("access_token_response: {:?}", access_token_response); + trace!("access_token_response: {:?}", access_token_response); let expires_at = SystemTime::now() + std::time::Duration::from_secs(access_token_response.expires_in); return Ok(ExpiringValue { @@ -397,7 +398,7 @@ pub async fn interactive_get_ms_auth_token( scope: Option<&str>, ) -> Result, GetMicrosoftAuthTokenError> { let res = get_ms_link_code(client, client_id, scope).await?; - tracing::trace!("Device code response: {:?}", res); + trace!("Device code response: {:?}", res); println!( "Go to \x1b[1m{}\x1b[m and enter the code \x1b[1m{}\x1b[m for \x1b[1m{}\x1b[m", res.verification_uri, res.user_code, email @@ -473,7 +474,7 @@ async fn auth_with_xbox_live( "TokenType": "JWT" }); let payload = auth_json.to_string(); - tracing::trace!("auth_json: {:#?}", auth_json); + trace!("auth_json: {:#?}", auth_json); let res = client .post("https://user.auth.xboxlive.com/user/authenticate") .header("Content-Type", "application/json") @@ -486,7 +487,7 @@ async fn auth_with_xbox_live( .await? .json::() .await?; - tracing::trace!("Xbox Live auth response: {:?}", res); + trace!("Xbox Live auth response: {:?}", res); // not_after looks like 2020-12-21T19:52:08.4463796Z let expires_at = DateTime::parse_from_rfc3339(&res.not_after) @@ -527,7 +528,7 @@ async fn obtain_xsts_for_minecraft( .await? .json::() .await?; - tracing::trace!("Xbox Live auth response (for XSTS): {:?}", res); + trace!("Xbox Live auth response (for XSTS): {:?}", res); Ok(res.token) } @@ -553,7 +554,7 @@ async fn auth_with_minecraft( .await? .json::() .await?; - tracing::trace!("{:?}", res); + trace!("{:?}", res); let expires_at = SystemTime::now() + std::time::Duration::from_secs(res.expires_in); Ok(ExpiringValue { @@ -580,7 +581,7 @@ pub async fn check_ownership( .await? .json::() .await?; - tracing::trace!("{:?}", res); + trace!("{:?}", res); // vanilla checks here to make sure the signatures are right, but it's not // actually required so we just don't @@ -605,7 +606,7 @@ pub async fn get_profile( .await? .json::() .await?; - tracing::trace!("{:?}", res); + trace!("{:?}", res); Ok(res) } diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs index 85d25f93..210dbab6 100755 --- a/azalea-auth/src/cache.rs +++ b/azalea-auth/src/cache.rs @@ -6,6 +6,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use thiserror::Error; use tokio::fs::File; use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tracing::{debug, trace}; #[derive(Debug, Error)] pub enum CacheError { @@ -82,13 +83,13 @@ async fn get_entire_cache(cache_file: &Path) -> Result, Cache Ok(cache) } async fn set_entire_cache(cache_file: &Path, cache: Vec) -> Result<(), CacheError> { - tracing::trace!("saving cache: {:?}", cache); + trace!("saving cache: {:?}", cache); if !cache_file.exists() { let cache_file_parent = cache_file .parent() .expect("Cache file is root directory and also doesn't exist."); - tracing::debug!( + debug!( "Making cache file parent directory at {}", cache_file_parent.to_string_lossy() ); diff --git a/azalea-auth/src/certs.rs b/azalea-auth/src/certs.rs index 6214142b..9f9147a8 100644 --- a/azalea-auth/src/certs.rs +++ b/azalea-auth/src/certs.rs @@ -3,6 +3,7 @@ use chrono::{DateTime, Utc}; use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey}; use serde::Deserialize; use thiserror::Error; +use tracing::trace; #[derive(Debug, Error)] pub enum FetchCertificatesError { @@ -26,7 +27,7 @@ pub async fn fetch_certificates( .await? .json::() .await?; - tracing::trace!("{:?}", res); + trace!("{:?}", res); // using RsaPrivateKey::from_pkcs8_pem gives an error with decoding base64 so we // just decode it ourselves diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs index 912271ae..82c84d85 100755 --- a/azalea-chat/src/translatable_component.rs +++ b/azalea-chat/src/translatable_component.rs @@ -51,6 +51,8 @@ fn serialize_args_as_nbt(args: &[StringOrComponent]) -> simdnbt::owned::NbtList // if it's all components then make it a compound list // if it's a mix then return an error + use tracing::debug; + let mut string_list = Vec::new(); let mut compound_list = Vec::new(); @@ -68,9 +70,7 @@ fn serialize_args_as_nbt(args: &[StringOrComponent]) -> simdnbt::owned::NbtList if !string_list.is_empty() && !compound_list.is_empty() { // i'm actually not sure what vanilla does here, so i just made it return the // string list - tracing::debug!( - "Tried to serialize a TranslatableComponent with a mix of strings and components." - ); + debug!("Tried to serialize a TranslatableComponent with a mix of strings and components."); return string_list.into(); } diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs index 24023d5b..87573de0 100755 --- a/azalea-client/src/account.rs +++ b/azalea-client/src/account.rs @@ -7,6 +7,7 @@ use azalea_auth::AccessTokenResponse; use bevy_ecs::component::Component; use parking_lot::Mutex; use thiserror::Error; +use tracing::trace; use uuid::Uuid; /// Something that can join Minecraft servers. @@ -135,7 +136,7 @@ impl Account { /// the authentication process (like doing your own caching or /// displaying the Microsoft user code to the user in a different way). /// - /// Note that this will not refresh the token when it expires. + /// This will refresh the given token if it's expired. /// /// ``` /// # use azalea_client::Account; @@ -170,7 +171,7 @@ impl Account { let client = reqwest::Client::new(); if msa.is_expired() { - tracing::trace!("refreshing Microsoft auth token"); + trace!("refreshing Microsoft auth token"); msa = azalea_auth::refresh_ms_auth_token( &client, &msa.data.refresh_token, diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 02d400fd..6cb590df 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -601,7 +601,7 @@ impl Client { } if self.logged_in() { - tracing::debug!( + debug!( "Sending client information (already logged in): {:?}", client_information );