aboutsummaryrefslogtreecommitdiff
path: root/azalea-auth/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-11-18 00:58:47 -0600
committermat <git@matdoes.dev>2023-11-18 00:58:47 -0600
commit9633508a3a31a70c657329fdeca0050b7082959e (patch)
tree9973ed4e60a0bd2b77413a195b2a166854f04d43 /azalea-auth/src
parentb79ae025f08935044c621259d4e0c4bb72bbcd7f (diff)
downloadazalea-drasl-9633508a3a31a70c657329fdeca0050b7082959e.tar.xz
replace log with tracing
Diffstat (limited to 'azalea-auth/src')
-rwxr-xr-xazalea-auth/src/auth.rs24
-rwxr-xr-xazalea-auth/src/cache.rs4
-rw-r--r--azalea-auth/src/certs.rs2
-rwxr-xr-xazalea-auth/src/sessionserver.rs2
4 files changed, 16 insertions, 16 deletions
diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs
index b0b30e1f..0c3b98c6 100755
--- a/azalea-auth/src/auth.rs
+++ b/azalea-auth/src/auth.rs
@@ -83,12 +83,12 @@ pub async fn auth(email: &str, opts: AuthOpts) -> Result<AuthResult, AuthError>
interactive_get_ms_auth_token(&client, email).await?
};
if msa.is_expired() {
- log::trace!("refreshing Microsoft auth token");
+ tracing::trace!("refreshing Microsoft auth token");
msa = refresh_ms_auth_token(&client, &msa.data.refresh_token).await?;
}
let msa_token = &msa.data.access_token;
- log::trace!("Got access token: {msa_token}");
+ tracing::trace!("Got access token: {msa_token}");
let res = get_minecraft_token(&client, msa_token).await?;
@@ -115,7 +115,7 @@ pub async fn auth(email: &str, opts: AuthOpts) -> Result<AuthResult, AuthError>
)
.await
{
- log::error!("{}", e);
+ tracing::error!("{}", e);
}
}
@@ -309,7 +309,7 @@ pub async fn get_ms_auth_token(
while Instant::now() < login_expires_at {
tokio::time::sleep(std::time::Duration::from_secs(res.interval)).await;
- log::trace!("Polling to check if user has logged in...");
+ tracing::trace!("Polling to check if user has logged in...");
if let Ok(access_token_response) = client
.post(format!(
"https://login.live.com/oauth20_token.srf?client_id={CLIENT_ID}"
@@ -324,7 +324,7 @@ pub async fn get_ms_auth_token(
.json::<AccessTokenResponse>()
.await
{
- log::trace!("access_token_response: {:?}", access_token_response);
+ tracing::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 {
@@ -348,7 +348,7 @@ pub async fn interactive_get_ms_auth_token(
email: &str,
) -> Result<ExpiringValue<AccessTokenResponse>, GetMicrosoftAuthTokenError> {
let res = get_ms_link_code(client).await?;
- log::trace!("Device code response: {:?}", res);
+ tracing::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
@@ -415,7 +415,7 @@ async fn auth_with_xbox_live(
"TokenType": "JWT"
});
let payload = auth_json.to_string();
- log::trace!("auth_json: {:#?}", auth_json);
+ tracing::trace!("auth_json: {:#?}", auth_json);
let res = client
.post("https://user.auth.xboxlive.com/user/authenticate")
.header("Content-Type", "application/json")
@@ -428,7 +428,7 @@ async fn auth_with_xbox_live(
.await?
.json::<XboxLiveAuthResponse>()
.await?;
- log::trace!("Xbox Live auth response: {:?}", res);
+ tracing::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)
@@ -469,7 +469,7 @@ async fn obtain_xsts_for_minecraft(
.await?
.json::<XboxLiveAuthResponse>()
.await?;
- log::trace!("Xbox Live auth response (for XSTS): {:?}", res);
+ tracing::trace!("Xbox Live auth response (for XSTS): {:?}", res);
Ok(res.token)
}
@@ -495,7 +495,7 @@ async fn auth_with_minecraft(
.await?
.json::<MinecraftAuthResponse>()
.await?;
- log::trace!("{:?}", res);
+ tracing::trace!("{:?}", res);
let expires_at = SystemTime::now() + std::time::Duration::from_secs(res.expires_in);
Ok(ExpiringValue {
@@ -522,7 +522,7 @@ async fn check_ownership(
.await?
.json::<GameOwnershipResponse>()
.await?;
- log::trace!("{:?}", res);
+ tracing::trace!("{:?}", res);
// vanilla checks here to make sure the signatures are right, but it's not
// actually required so we just don't
@@ -547,7 +547,7 @@ pub async fn get_profile(
.await?
.json::<ProfileResponse>()
.await?;
- log::trace!("{:?}", res);
+ tracing::trace!("{:?}", res);
Ok(res)
}
diff --git a/azalea-auth/src/cache.rs b/azalea-auth/src/cache.rs
index 1e8aee10..85d25f93 100755
--- a/azalea-auth/src/cache.rs
+++ b/azalea-auth/src/cache.rs
@@ -82,13 +82,13 @@ async fn get_entire_cache(cache_file: &Path) -> Result<Vec<CachedAccount>, Cache
Ok(cache)
}
async fn set_entire_cache(cache_file: &Path, cache: Vec<CachedAccount>) -> Result<(), CacheError> {
- log::trace!("saving cache: {:?}", cache);
+ tracing::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.");
- log::debug!(
+ tracing::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 6030b886..6214142b 100644
--- a/azalea-auth/src/certs.rs
+++ b/azalea-auth/src/certs.rs
@@ -26,7 +26,7 @@ pub async fn fetch_certificates(
.await?
.json::<CertificatesResponse>()
.await?;
- log::trace!("{:?}", res);
+ tracing::trace!("{:?}", res);
// using RsaPrivateKey::from_pkcs8_pem gives an error with decoding base64 so we
// just decode it ourselves
diff --git a/azalea-auth/src/sessionserver.rs b/azalea-auth/src/sessionserver.rs
index d6e20bc5..e6469cef 100755
--- a/azalea-auth/src/sessionserver.rs
+++ b/azalea-auth/src/sessionserver.rs
@@ -1,10 +1,10 @@
//! Tell Mojang you're joining a multiplayer server.
-use log::debug;
use once_cell::sync::Lazy;
use reqwest::StatusCode;
use serde::Deserialize;
use serde_json::json;
use thiserror::Error;
+use tracing::debug;
use uuid::Uuid;
use crate::game_profile::{GameProfile, SerializableGameProfile};