Skip to content

Commit

Permalink
replace log with tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Nov 18, 2023
1 parent b79ae02 commit 9633508
Show file tree
Hide file tree
Showing 40 changed files with 63 additions and 64 deletions.
19 changes: 9 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azalea-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ azalea-buf = { path = "../azalea-buf", version = "0.8.0" }
azalea-crypto = { path = "../azalea-crypto", version = "0.8.0" }
base64 = "0.21.5"
chrono = { version = "0.4.31", default-features = false, features = ["serde"] }
log = "0.4.20"
tracing = "0.1.40"
num-bigint = "0.4.4"
once_cell = "1.18.0"
reqwest = { version = "0.11.22", default-features = false, features = [
Expand Down
24 changes: 12 additions & 12 deletions azalea-auth/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand All @@ -115,7 +115,7 @@ pub async fn auth(email: &str, opts: AuthOpts) -> Result<AuthResult, AuthError>
)
.await
{
log::error!("{}", e);
tracing::error!("{}", e);
}
}

Expand Down Expand Up @@ -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}"
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -547,7 +547,7 @@ pub async fn get_profile(
.await?
.json::<ProfileResponse>()
.await?;
log::trace!("{:?}", res);
tracing::trace!("{:?}", res);

Ok(res)
}
4 changes: 2 additions & 2 deletions azalea-auth/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down
2 changes: 1 addition & 1 deletion azalea-auth/src/certs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion azalea-auth/src/sessionserver.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 1 addition & 1 deletion azalea-buf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = "0.8.0"
[dependencies]
azalea-buf-macros = { path = "./azalea-buf-macros", version = "0.8.0" }
byteorder = "^1.5.0"
log = "0.4.20"
tracing = "0.1.40"
serde_json = { version = "^1.0", optional = true }
thiserror = "1.0.50"
uuid = "^1.5.0"
Expand Down
2 changes: 1 addition & 1 deletion azalea-buf/src/read.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::{UnsizedByteArray, MAX_STRING_LENGTH};
use byteorder::{ReadBytesExt, BE};
use log::warn;
use std::{
backtrace::Backtrace,
collections::HashMap,
hash::Hash,
io::{Cursor, Read},
};
use thiserror::Error;
use tracing::warn;

#[derive(Error, Debug)]
pub enum BufReadError {
Expand Down
2 changes: 1 addition & 1 deletion azalea-chat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ azalea-buf = { path = "../azalea-buf", features = [
"serde_json",
], version = "^0.8.0", optional = true }
azalea-language = { path = "../azalea-language", version = "0.8.0" }
log = "0.4.20"
tracing = "0.1.40"
once_cell = "1.18.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0.108"
2 changes: 1 addition & 1 deletion azalea-chat/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::{
};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
use log::debug;
use once_cell::sync::Lazy;
use serde::{de, Deserialize, Deserializer, Serialize};
use std::{
fmt::Display,
io::{Cursor, Write},
};
use tracing::debug;

/// A chat component, basically anything you can see in chat.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bevy_time = "0.12.0"
azalea-inventory = { path = "../azalea-inventory", version = "0.8.0" }
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
futures = "0.3.29"
log = "0.4.20"
tracing = "0.1.40"
nohash-hasher = "0.2.0"
once_cell = "1.18.0"
parking_lot = { version = "^0.12.1", features = ["deadlock_detection"] }
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl Account {
let client = reqwest::Client::new();

if msa.is_expired() {
log::trace!("refreshing Microsoft auth token");
tracing::trace!("refreshing Microsoft auth token");
msa = azalea_auth::refresh_ms_auth_token(&client, &msa.data.refresh_token).await?;
}

Expand Down
4 changes: 2 additions & 2 deletions azalea-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ use bevy_ecs::{
};
use bevy_time::{Fixed, Time, TimePlugin};
use derive_more::Deref;
use log::{debug, error};
use parking_lot::{Mutex, RwLock};
use std::{
collections::HashMap, fmt::Debug, io, net::SocketAddr, ops::Deref, sync::Arc, time::Duration,
Expand All @@ -75,6 +74,7 @@ use tokio::{
sync::{broadcast, mpsc},
time,
};
use tracing::{debug, error};
use uuid::Uuid;

/// `Client` has the things that a user interacting with the library will want.
Expand Down Expand Up @@ -518,7 +518,7 @@ impl Client {
}

if self.logged_in() {
log::debug!(
tracing::debug!(
"Sending client information (already logged in): {:?}",
client_information
);
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use bevy_ecs::{
system::{Commands, Query, Res},
};
use derive_more::{Deref, DerefMut};
use log::warn;
use tracing::warn;

use crate::{
attack::handle_attack_event,
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use bevy_ecs::{
schedule::{IntoSystemConfigs, SystemSet},
system::Query,
};
use log::warn;
use tracing::warn;

use crate::{
local_player::{handle_send_packet_event, PlayerAbilities, SendPacketEvent},
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/local_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use bevy_ecs::{
system::Query,
};
use derive_more::{Deref, DerefMut};
use log::error;
use parking_lot::RwLock;
use thiserror::Error;
use tokio::sync::mpsc;
use tracing::error;
use uuid::Uuid;

use crate::{
Expand Down
Loading

0 comments on commit 9633508

Please sign in to comment.