From 9633508a3a31a70c657329fdeca0050b7082959e Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 18 Nov 2023 00:58:47 -0600 Subject: [PATCH] replace log with tracing --- Cargo.lock | 19 +++++++-------- azalea-auth/Cargo.toml | 2 +- azalea-auth/src/auth.rs | 24 +++++++++---------- azalea-auth/src/cache.rs | 4 ++-- azalea-auth/src/certs.rs | 2 +- azalea-auth/src/sessionserver.rs | 2 +- azalea-buf/Cargo.toml | 2 +- azalea-buf/src/read.rs | 2 +- azalea-chat/Cargo.toml | 2 +- azalea-chat/src/component.rs | 2 +- azalea-client/Cargo.toml | 2 +- azalea-client/src/account.rs | 2 +- azalea-client/src/client.rs | 4 ++-- azalea-client/src/interact.rs | 2 +- azalea-client/src/inventory.rs | 2 +- azalea-client/src/local_player.rs | 2 +- .../src/packet_handling/configuration.rs | 2 +- azalea-client/src/packet_handling/game.rs | 2 +- azalea-client/src/raw_connection.rs | 2 +- azalea-entity/Cargo.toml | 2 +- azalea-entity/src/plugin/indexing.rs | 2 +- azalea-entity/src/plugin/mod.rs | 2 +- azalea-entity/src/plugin/relative_updates.rs | 2 +- azalea-nbt/Cargo.toml | 2 +- azalea-nbt/src/decode.rs | 2 +- azalea-physics/Cargo.toml | 2 +- azalea-protocol/Cargo.toml | 2 +- azalea-protocol/examples/handshake_proxy.rs | 2 +- azalea-protocol/src/connect.rs | 2 +- .../game/clientbound_commands_packet.rs | 2 +- azalea-protocol/src/read.rs | 6 ++--- azalea-protocol/src/write.rs | 2 +- azalea-world/Cargo.toml | 2 +- azalea-world/src/chunk_storage.rs | 2 +- azalea-world/src/container.rs | 2 +- azalea/Cargo.toml | 2 +- azalea/src/bot.rs | 2 +- azalea/src/pathfinder/astar.rs | 2 +- azalea/src/pathfinder/mod.rs | 2 +- azalea/src/swarm/mod.rs | 2 +- 40 files changed, 63 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a8cbd42..e416e35c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", ] diff --git a/azalea-auth/Cargo.toml b/azalea-auth/Cargo.toml index 8f2acc27..8bdb8731 100644 --- a/azalea-auth/Cargo.toml +++ b/azalea-auth/Cargo.toml @@ -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 = [ 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 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 ) .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::() .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, 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::() .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::() .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::() .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::() .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::() .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, Cache Ok(cache) } async fn set_entire_cache(cache_file: &Path, cache: Vec) -> 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::() .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}; diff --git a/azalea-buf/Cargo.toml b/azalea-buf/Cargo.toml index 22b6701d..95f3b4ac 100644 --- a/azalea-buf/Cargo.toml +++ b/azalea-buf/Cargo.toml @@ -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" diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 8b37ff6a..b4b54917 100755 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -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 { diff --git a/azalea-chat/Cargo.toml b/azalea-chat/Cargo.toml index da274125..96b3da9f 100644 --- a/azalea-chat/Cargo.toml +++ b/azalea-chat/Cargo.toml @@ -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" diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs index fb7e0522..e80e7e4b 100755 --- a/azalea-chat/src/component.rs +++ b/azalea-chat/src/component.rs @@ -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)] diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index 655cd1a5..b95edeed 100644 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -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"] } diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs index d045cc72..0be4146b 100755 --- a/azalea-client/src/account.rs +++ b/azalea-client/src/account.rs @@ -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?; } diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 13d180fe..96e4eb1c 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -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 ); diff --git a/azalea-client/src/interact.rs b/azalea-client/src/interact.rs index eaced255..64cbd7be 100644 --- a/azalea-client/src/interact.rs +++ b/azalea-client/src/interact.rs @@ -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, diff --git a/azalea-client/src/inventory.rs b/azalea-client/src/inventory.rs index 356e0c0b..e1ac9dd4 100644 --- a/azalea-client/src/inventory.rs +++ b/azalea-client/src/inventory.rs @@ -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}, diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs index ac0e4ea1..db0a14f1 100644 --- a/azalea-client/src/local_player.rs +++ b/azalea-client/src/local_player.rs @@ -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::{ diff --git a/azalea-client/src/packet_handling/configuration.rs b/azalea-client/src/packet_handling/configuration.rs index b61b2e7e..b82ed76f 100644 --- a/azalea-client/src/packet_handling/configuration.rs +++ b/azalea-client/src/packet_handling/configuration.rs @@ -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; diff --git a/azalea-client/src/packet_handling/game.rs b/azalea-client/src/packet_handling/game.rs index dad4a555..dba0e070 100644 --- a/azalea-client/src/packet_handling/game.rs +++ b/azalea-client/src/packet_handling/game.rs @@ -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}, diff --git a/azalea-client/src/raw_connection.rs b/azalea-client/src/raw_connection.rs index 0df13a60..e2daaba2 100644 --- a/azalea-client/src/raw_connection.rs +++ b/azalea-client/src/raw_connection.rs @@ -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 diff --git a/azalea-entity/Cargo.toml b/azalea-entity/Cargo.toml index 7cde8c71..4399ddf3 100644 --- a/azalea-entity/Cargo.toml +++ b/azalea-entity/Cargo.toml @@ -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" diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs index 3ae17f7b..86e91ff2 100644 --- a/azalea-entity/src/plugin/indexing.rs +++ b/azalea-entity/src/plugin/indexing.rs @@ -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}; diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index 2e5a3244..9950e6ba 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -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, diff --git a/azalea-entity/src/plugin/relative_updates.rs b/azalea-entity/src/plugin/relative_updates.rs index 140c54e9..63b00195 100644 --- a/azalea-entity/src/plugin/relative_updates.rs +++ b/azalea-entity/src/plugin/relative_updates.rs @@ -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; diff --git a/azalea-nbt/Cargo.toml b/azalea-nbt/Cargo.toml index 4f78adb9..788d4a07 100644 --- a/azalea-nbt/Cargo.toml +++ b/azalea-nbt/Cargo.toml @@ -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" diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs index b2cc8c77..23247b74 100755 --- a/azalea-nbt/src/decode.rs +++ b/azalea-nbt/src/decode.rs @@ -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> { diff --git a/azalea-physics/Cargo.toml b/azalea-physics/Cargo.toml index 97751f23..f79ddf43 100644 --- a/azalea-physics/Cargo.toml +++ b/azalea-physics/Cargo.toml @@ -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" diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml index 4c849573..934152e5 100644 --- a/azalea-protocol/Cargo.toml +++ b/azalea-protocol/Cargo.toml @@ -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" diff --git a/azalea-protocol/examples/handshake_proxy.rs b/azalea-protocol/examples/handshake_proxy.rs index f7fb0f5c..4e9719b0 100644 --- a/azalea-protocol/examples/handshake_proxy.rs +++ b/azalea-protocol/examples/handshake_proxy.rs @@ -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"; diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index 9c573506..86b92693 100755 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -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 { diff --git a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs index 0b14fbd1..0bc436be 100755 --- a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs @@ -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 { diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 4002f4cb..d1985b31 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -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)) } diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs index 0c3131a0..6ce01bf7 100755 --- a/azalea-protocol/src/write.rs +++ b/azalea-protocol/src/write.rs @@ -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) -> Result, std::io::Error> { diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml index 02f4d3ed..2d83e1b2 100644 --- a/azalea-world/Cargo.toml +++ b/azalea-world/Cargo.toml @@ -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" diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index 03bdcbb5..80854f0a 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -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; diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs index 471e1d5e..1e2dfef7 100644 --- a/azalea-world/src/container.rs +++ b/azalea-world/src/container.rs @@ -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}; diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml index c3133d13..c411aaae 100644 --- a/azalea/Cargo.toml +++ b/azalea/Cargo.toml @@ -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"] } diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs index 4fe10e74..2281deaf 100644 --- a/azalea/src/bot.rs +++ b/azalea/src/bot.rs @@ -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; diff --git a/azalea/src/pathfinder/astar.rs b/azalea/src/pathfinder/astar.rs index 98525e03..163189af 100644 --- a/azalea/src/pathfinder/astar.rs +++ b/azalea/src/pathfinder/astar.rs @@ -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 where diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index c7f05eae..db508004 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -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}; diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 585e2608..05aabe68 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -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};