1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

replace log with tracing

This commit is contained in:
mat 2023-11-18 00:58:47 -06:00
parent b79ae025f0
commit 9633508a3a
40 changed files with 63 additions and 64 deletions

19
Cargo.lock generated
View file

@ -188,7 +188,6 @@ dependencies = [
"derive_more",
"futures",
"futures-lite 2.0.1",
"log",
"nohash-hasher",
"num-traits",
"parking_lot",
@ -197,6 +196,7 @@ dependencies = [
"rustc-hash",
"thiserror",
"tokio",
"tracing",
"uuid",
]
@ -209,7 +209,6 @@ dependencies = [
"base64",
"chrono",
"env_logger",
"log",
"num-bigint",
"once_cell",
"reqwest",
@ -218,6 +217,7 @@ dependencies = [
"serde_json",
"thiserror",
"tokio",
"tracing",
"uuid",
]
@ -254,9 +254,9 @@ version = "0.8.0"
dependencies = [
"azalea-buf-macros",
"byteorder",
"log",
"serde_json",
"thiserror",
"tracing",
"uuid",
]
@ -275,10 +275,10 @@ version = "0.8.0"
dependencies = [
"azalea-buf",
"azalea-language",
"log",
"once_cell",
"serde",
"serde_json",
"tracing",
]
[[package]]
@ -307,7 +307,6 @@ dependencies = [
"bevy_time",
"derive_more",
"futures",
"log",
"nohash-hasher",
"once_cell",
"parking_lot",
@ -317,6 +316,7 @@ dependencies = [
"serde_json",
"thiserror",
"tokio",
"tracing",
"uuid",
]
@ -368,10 +368,10 @@ dependencies = [
"bevy_ecs",
"derive_more",
"enum-as-inner",
"log",
"nohash-hasher",
"parking_lot",
"thiserror",
"tracing",
"uuid",
]
@ -415,9 +415,9 @@ dependencies = [
"fastnbt",
"flate2",
"graphite_binary",
"log",
"serde",
"thiserror",
"tracing",
"valence_nbt",
]
@ -434,9 +434,9 @@ dependencies = [
"bevy_app",
"bevy_ecs",
"bevy_time",
"log",
"once_cell",
"parking_lot",
"tracing",
"uuid",
]
@ -467,7 +467,6 @@ dependencies = [
"futures",
"futures-lite 2.0.1",
"futures-util",
"log",
"once_cell",
"serde",
"serde_json",
@ -523,11 +522,11 @@ dependencies = [
"criterion",
"derive_more",
"enum-as-inner",
"log",
"nohash-hasher",
"once_cell",
"parking_lot",
"thiserror",
"tracing",
"uuid",
]

View file

@ -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 = [

View file

@ -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)
}

View file

@ -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()
);

View file

@ -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

View file

@ -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};

View file

@ -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"

View file

@ -1,6 +1,5 @@
use super::{UnsizedByteArray, MAX_STRING_LENGTH};
use byteorder::{ReadBytesExt, BE};
use log::warn;
use std::{
backtrace::Backtrace,
collections::HashMap,
@ -8,6 +7,7 @@ use std::{
io::{Cursor, Read},
};
use thiserror::Error;
use tracing::warn;
#[derive(Error, Debug)]
pub enum BufReadError {

View file

@ -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"

View file

@ -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)]

View file

@ -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"] }

View file

@ -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?;
}

View file

@ -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,
@ -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.
@ -518,7 +518,7 @@ impl Client {
}
if self.logged_in() {
log::debug!(
tracing::debug!(
"Sending client information (already logged in): {:?}",
client_information
);

View file

@ -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,

View file

@ -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},

View file

@ -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::{

View file

@ -12,8 +12,8 @@ use azalea_protocol::read::deserialize_packet;
use azalea_world::Instance;
use bevy_ecs::prelude::*;
use bevy_ecs::system::SystemState;
use log::{debug, error, warn};
use parking_lot::RwLock;
use tracing::{debug, error, warn};
use crate::client::InConfigurationState;
use crate::disconnect::DisconnectEvent;

View file

@ -29,8 +29,8 @@ use azalea_protocol::{
};
use azalea_world::{Instance, InstanceContainer, InstanceName, MinecraftEntityId, PartialInstance};
use bevy_ecs::{prelude::*, system::SystemState};
use log::{debug, error, trace, warn};
use parking_lot::RwLock;
use tracing::{debug, error, trace, warn};
use crate::{
chat::{ChatPacket, ChatReceivedEvent},

View file

@ -8,10 +8,10 @@ use azalea_protocol::{
write::serialize_packet,
};
use bevy_ecs::prelude::*;
use log::error;
use parking_lot::Mutex;
use thiserror::Error;
use tokio::sync::mpsc;
use tracing::error;
/// A component for clients that can read and write packets to the server. This
/// works with raw bytes, so you'll have to serialize/deserialize packets

View file

@ -21,7 +21,7 @@ bevy_app = "0.12.0"
bevy_ecs = "0.12.0"
derive_more = "0.99.17"
enum-as-inner = "0.6.0"
log = "0.4.20"
tracing = "0.1.40"
nohash-hasher = "0.2.0"
parking_lot = "0.12.1"
thiserror = "1.0.50"

View file

@ -8,9 +8,9 @@ use bevy_ecs::{
query::Changed,
system::{Commands, Query, Res, ResMut, Resource},
};
use log::{debug, warn};
use nohash_hasher::IntMap;
use std::{collections::HashMap, fmt::Debug};
use tracing::{debug, warn};
use uuid::Uuid;
use crate::{EntityUuid, LastSentPosition, Position};

View file

@ -8,7 +8,7 @@ use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId};
use bevy_app::{App, Plugin, PreUpdate, Update};
use bevy_ecs::prelude::*;
use derive_more::{Deref, DerefMut};
use log::debug;
use tracing::debug;
use crate::{
metadata::Health, Dead, EyeHeight, FluidOnEyes, LocalEntity, LookDirection, Physics, Position,

View file

@ -25,8 +25,8 @@ use bevy_ecs::{
world::{EntityWorldMut, World},
};
use derive_more::{Deref, DerefMut};
use log::warn;
use parking_lot::RwLock;
use tracing::warn;
use crate::LocalEntity;

View file

@ -14,7 +14,7 @@ byteorder = "^1.5.0"
compact_str = { version = "0.7.1", features = ["serde"] }
enum-as-inner = "0.6.0"
flate2 = "^1.0.28"
log = "0.4.20"
tracing = "0.1.40"
serde = { version = "^1.0", features = ["derive"], optional = true }
thiserror = "1.0.50"

View file

@ -3,8 +3,8 @@ use crate::Error;
use azalea_buf::{BufReadError, McBufReadable};
use byteorder::{ReadBytesExt, BE};
use flate2::read::{GzDecoder, ZlibDecoder};
use log::warn;
use std::io::{BufRead, Cursor, Read};
use tracing::warn;
#[inline]
fn read_bytes<'a>(buf: &'a mut Cursor<&[u8]>, length: usize) -> Result<&'a [u8], Error> {

View file

@ -17,7 +17,7 @@ azalea-registry = { path = "../azalea-registry", version = "0.8.0" }
azalea-world = { path = "../azalea-world", version = "0.8.0" }
bevy_app = "0.12.0"
bevy_ecs = "0.12.0"
log = "0.4.20"
tracing = "0.1.40"
once_cell = "1.18.0"
parking_lot = "^0.12.1"

View file

@ -40,7 +40,7 @@ flate2 = "1.0.28"
futures = "0.3.29"
futures-lite = "2.0.1"
futures-util = "0.3.29"
log = "0.4.20"
tracing = "0.1.40"
serde = { version = "^1.0", features = ["serde_derive"] }
serde_json = "^1.0.108"
thiserror = "1.0.50"

View file

@ -21,7 +21,6 @@ use azalea_protocol::{
read::ReadPacketError,
};
use futures::FutureExt;
use log::{error, info, warn};
use once_cell::sync::Lazy;
use std::error::Error;
use tokio::{
@ -29,6 +28,7 @@ use tokio::{
net::{TcpListener, TcpStream},
};
use tracing::Level;
use tracing::{error, info, warn};
const LISTEN_ADDR: &str = "127.0.0.1:25566";
const PROXY_ADDR: &str = "127.0.0.1:25565";

View file

@ -15,7 +15,6 @@ use azalea_auth::game_profile::GameProfile;
use azalea_auth::sessionserver::{ClientSessionServerError, ServerSessionServerError};
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
use bytes::BytesMut;
use log::{error, info};
use std::fmt::Debug;
use std::io::Cursor;
use std::marker::PhantomData;
@ -24,6 +23,7 @@ use thiserror::Error;
use tokio::io::AsyncWriteExt;
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf, ReuniteError};
use tokio::net::TcpStream;
use tracing::{error, info};
use uuid::Uuid;
pub struct RawReadConnection {

View file

@ -3,8 +3,8 @@ use azalea_buf::{
};
use azalea_core::{bitset::FixedBitSet, resource_location::ResourceLocation};
use azalea_protocol_macros::ClientboundGamePacket;
use log::warn;
use std::io::{Cursor, Write};
use tracing::warn;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundCommandsPacket {

View file

@ -9,7 +9,6 @@ use bytes::BytesMut;
use flate2::read::ZlibDecoder;
use futures::StreamExt;
use futures_lite::future;
use log::{log_enabled, trace};
use std::backtrace::Backtrace;
use std::{
fmt::Debug,
@ -18,6 +17,7 @@ use std::{
use thiserror::Error;
use tokio::io::AsyncRead;
use tokio_util::codec::{BytesCodec, FramedRead};
use tracing::if_log_enabled;
#[derive(Error, Debug)]
pub enum ReadPacketError {
@ -346,7 +346,7 @@ where
.map_err(ReadPacketError::from)?;
}
if log_enabled!(log::Level::Trace) {
if_log_enabled!(tracing::Level::TRACE, {
let buf_string: String = {
if buf.len() > 500 {
let cut_off_buf = &buf[..500];
@ -356,7 +356,7 @@ where
}
};
trace!("Reading packet with bytes: {buf_string}");
}
});
Ok(Some(buf))
}

View file

@ -4,10 +4,10 @@ use crate::{packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH};
use async_compression::tokio::bufread::ZlibEncoder;
use azalea_buf::McBufVarWritable;
use azalea_crypto::Aes128CfbEnc;
use log::trace;
use std::fmt::Debug;
use thiserror::Error;
use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tracing::trace;
/// Prepend the length of the packet to it.
fn frame_prepender(mut data: Vec<u8>) -> Result<Vec<u8>, std::io::Error> {

View file

@ -20,7 +20,7 @@ azalea-registry = { path = "../azalea-registry", version = "0.8.0" }
bevy_ecs = "0.12.0"
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
enum-as-inner = "0.6.0"
log = "0.4.20"
tracing = "0.1.40"
nohash-hasher = "0.2.0"
once_cell = "1.18.0"
parking_lot = "^0.12.1"

View file

@ -6,7 +6,6 @@ use azalea_block::BlockState;
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
use azalea_core::position::{BlockPos, ChunkBlockPos, ChunkPos, ChunkSectionBlockPos};
use azalea_nbt::NbtCompound;
use log::{debug, trace, warn};
use nohash_hasher::IntMap;
use parking_lot::RwLock;
use std::str::FromStr;
@ -16,6 +15,7 @@ use std::{
io::{Cursor, Write},
sync::{Arc, Weak},
};
use tracing::{debug, trace, warn};
const SECTION_HEIGHT: u32 = 16;

View file

@ -1,13 +1,13 @@
use azalea_core::resource_location::ResourceLocation;
use bevy_ecs::{component::Component, system::Resource};
use derive_more::{Deref, DerefMut};
use log::error;
use nohash_hasher::IntMap;
use parking_lot::RwLock;
use std::{
collections::HashMap,
sync::{Arc, Weak},
};
use tracing::error;
use crate::{ChunkStorage, Instance};

View file

@ -31,7 +31,7 @@ bevy_tasks = { version = "0.12.0", features = ["multi-threaded"] }
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
futures = "0.3.29"
futures-lite = "2.0.1"
log = "0.4.20"
tracing = "0.1.40"
nohash-hasher = "0.2.0"
num-traits = "0.2.17"
parking_lot = { version = "^0.12.1", features = ["deadlock_detection"] }

View file

@ -22,8 +22,8 @@ use bevy_app::{FixedUpdate, Update};
use bevy_ecs::prelude::Event;
use bevy_ecs::schedule::IntoSystemConfigs;
use futures_lite::Future;
use log::trace;
use std::f64::consts::PI;
use tracing::trace;
use crate::pathfinder::PathfinderPlugin;

View file

@ -5,9 +5,9 @@ use std::{
time::{Duration, Instant},
};
use log::{debug, trace, warn};
use priority_queue::PriorityQueue;
use rustc_hash::FxHashMap;
use tracing::{debug, trace, warn};
pub struct Path<P, M>
where

View file

@ -41,11 +41,11 @@ use bevy_ecs::schedule::IntoSystemConfigs;
use bevy_ecs::system::{Local, ResMut};
use bevy_tasks::{AsyncComputeTaskPool, Task};
use futures_lite::future;
use log::{debug, error, info, trace, warn};
use std::collections::VecDeque;
use std::sync::atomic::{self, AtomicUsize};
use std::sync::Arc;
use std::time::{Duration, Instant};
use tracing::{debug, error, info, trace, warn};
use self::mining::MiningCache;
use self::moves::{ExecuteCtx, IsReachedCtx, SuccessorsFn};

View file

@ -16,11 +16,11 @@ use azalea_world::InstanceContainer;
use bevy_app::{App, PluginGroup, PluginGroupBuilder, Plugins};
use bevy_ecs::{component::Component, entity::Entity, system::Resource, world::World};
use futures::future::{join_all, BoxFuture};
use log::error;
use parking_lot::{Mutex, RwLock};
use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc, time::Duration};
use thiserror::Error;
use tokio::sync::mpsc;
use tracing::error;
use crate::{BoxHandleFn, DefaultBotPlugins, HandleFn, NoState};