Replace log crate with tracing

This commit is contained in:
Jackson Coxson
2025-10-23 09:49:38 -06:00
parent 18b8b7295c
commit a297eed156
91 changed files with 323 additions and 342 deletions

View File

@@ -24,8 +24,7 @@ serde = { version = "1", features = ["derive"] }
ns-keyed-archive = { version = "0.1.4", optional = true }
thiserror = { version = "2" }
log = { version = "0.4" }
env_logger = { version = "0.11" }
tracing = { version = "0.1.41" }
base64 = { version = "0.22" }
indexmap = { version = "2.11", features = ["serde"], optional = true }

View File

@@ -26,7 +26,6 @@ pub use services::*;
#[cfg(feature = "xpc")]
pub use xpc::RemoteXpcClient;
use log::{debug, error, trace};
use provider::{IdeviceProvider, RsdProvider};
use rustls::{crypto::CryptoProvider, pki_types::ServerName};
use std::{
@@ -35,6 +34,7 @@ use std::{
};
use thiserror::Error;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tracing::{debug, error, trace};
pub use util::{pretty_print_dictionary, pretty_print_plist};
@@ -389,7 +389,7 @@ impl Idevice {
}
}
_ => {
log::error!("Error is not a string or integer from read_plist: {e:?}");
tracing::error!("Error is not a string or integer from read_plist: {e:?}");
return Err(IdeviceError::UnexpectedResponse);
}
};
@@ -488,7 +488,7 @@ impl Idevice {
// My sanity while debugging the workspace crates are more important.
debug!("Using ring crypto backend, because both were passed");
log::warn!("Both ring && aws-lc are selected as idevice crypto backends!");
tracing::warn!("Both ring && aws-lc are selected as idevice crypto backends!");
rustls::crypto::ring::default_provider()
}
};
@@ -497,7 +497,7 @@ impl Idevice {
// For whatever reason, getting the default provider will return None on iOS at
// random. Installing the default provider a second time will return an error, so
// we will log it but not propogate it. An issue should be opened with rustls.
log::error!("Failed to set crypto provider: {e:?}");
tracing::error!("Failed to set crypto provider: {e:?}");
}
}
let config = sni::create_client_config(pairing_file)?;

View File

@@ -5,10 +5,10 @@
use std::path::Path;
use log::warn;
use plist::Data;
use rustls::pki_types::{CertificateDer, pem::PemObject};
use serde::{Deserialize, Serialize};
use tracing::warn;
/// Represents a complete iOS device pairing record
///

View File

@@ -7,9 +7,9 @@ use std::collections::HashMap;
use errors::AfcError;
use file::FileDescriptor;
use log::warn;
use opcode::{AfcFopenMode, AfcOpcode};
use packet::{AfcPacket, AfcPacketHeader};
use tracing::warn;
use crate::{Idevice, IdeviceError, IdeviceService, obf};
@@ -508,7 +508,7 @@ impl AfcClient {
let res = AfcPacket::read(&mut self.idevice).await?;
if res.header.operation == AfcOpcode::Status {
if res.header_payload.len() < 8 {
log::error!("AFC returned error opcode, but not a code");
tracing::error!("AFC returned error opcode, but not a code");
return Err(IdeviceError::UnexpectedResponse);
}
let code = u64::from_le_bytes(res.header_payload[..8].try_into().unwrap());

View File

@@ -1,6 +1,6 @@
// Jackson Coxson
use log::debug;
use tracing::debug;
use crate::{Idevice, IdeviceError};

View File

@@ -5,7 +5,7 @@
use std::pin::Pin;
use futures::Stream;
use log::warn;
use tracing::warn;
use crate::{Idevice, IdeviceError, IdeviceService, obf};

View File

@@ -1,6 +1,6 @@
//! Companion Proxy is Apple's bridge to connect to the Apple Watch
use log::warn;
use tracing::warn;
use crate::{Idevice, IdeviceError, IdeviceService, RsdService, obf};

View File

@@ -1,7 +1,7 @@
// Jackson Coxson
use log::warn;
use serde::Deserialize;
use tracing::warn;
use crate::{IdeviceError, ReadWrite, RsdService, obf, xpc::XPCObject};

View File

@@ -3,7 +3,7 @@
use std::pin::Pin;
use futures::Stream;
use log::warn;
use tracing::warn;
use crate::{IdeviceError, ReadWrite, RsdService, obf};

View File

@@ -1,7 +1,7 @@
// Jackson Coxson
// Ported from pymobiledevice3
use log::warn;
use tracing::warn;
use crate::{
IdeviceError, ReadWrite, RemoteXpcClient,

View File

@@ -7,7 +7,7 @@
//! function to trigger a flush of crash logs from system storage into the
//! crash reports directory by connecting to the `com.apple.crashreportmover` service.
use log::{debug, warn};
use tracing::{debug, warn};
use crate::{Idevice, IdeviceError, IdeviceService, afc::AfcClient, lockdown::LockdownClient, obf};

View File

@@ -4,9 +4,9 @@
//! GDB Remote Serial Protocol as documented at:
//! https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#Packets
use log::debug;
use std::fmt::Write;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tracing::debug;
use crate::{IdeviceError, ReadWrite, RsdService, obf};

View File

@@ -10,8 +10,8 @@ use crate::{
},
obf,
};
use log::warn;
use plist::Value;
use tracing::warn;
#[derive(Debug)]
pub struct NotificationInfo {

View File

@@ -34,8 +34,8 @@
//! }
//! ```
use log::warn;
use plist::{Dictionary, Value};
use tracing::warn;
use crate::{IdeviceError, ReadWrite, dvt::message::AuxValue, obf};

View File

@@ -51,8 +51,8 @@
use std::collections::{HashMap, VecDeque};
use log::{debug, warn};
use tokio::io::AsyncWriteExt;
use tracing::{debug, warn};
use crate::{
IdeviceError, ReadWrite,

View File

@@ -5,8 +5,8 @@
use std::collections::HashMap;
use log::warn;
use plist::Dictionary;
use tracing::warn;
use crate::{Idevice, IdeviceError, IdeviceService, obf};

View File

@@ -3,8 +3,8 @@
//! Provides functionality for interacting with the lockdown service on iOS devices,
//! which is the primary service for device management and service discovery.
use log::error;
use plist::Value;
use tracing::error;
use crate::{Idevice, IdeviceError, IdeviceService, obf, pairing_file};
@@ -256,7 +256,7 @@ impl LockdownClient {
let pub_key = match pub_key.as_data().map(|x| x.to_vec()) {
Some(p) => p,
None => {
log::warn!("Did not get public key data response");
tracing::warn!("Did not get public key data response");
return Err(IdeviceError::UnexpectedResponse);
}
};
@@ -265,7 +265,7 @@ impl LockdownClient {
let wifi_mac = match wifi_mac.as_string() {
Some(w) => w,
None => {
log::warn!("Did not get WiFiAddress string");
tracing::warn!("Did not get WiFiAddress string");
return Err(IdeviceError::UnexpectedResponse);
}
};

View File

@@ -3,7 +3,7 @@
//! Provides functionality for interacting with the misagent service on iOS devices,
//! which manages provisioning profiles and certificates.
use log::warn;
use tracing::warn;
use crate::{Idevice, IdeviceError, IdeviceService, RsdService, obf};

View File

@@ -7,7 +7,7 @@
//!
//! Handles the complete workflow from uploading images to mounting them with proper signatures.
use log::debug;
use tracing::debug;
use crate::{Idevice, IdeviceError, IdeviceService, obf};
use sha2::{Digest, Sha384};
@@ -145,7 +145,7 @@ impl ImageMounter {
let image_size = match u64::try_from(image.len()) {
Ok(i) => i,
Err(e) => {
log::error!("Could not parse image size as u64: {e:?}");
tracing::error!("Could not parse image size as u64: {e:?}");
return Err(IdeviceError::UnexpectedResponse);
}
};
@@ -162,7 +162,7 @@ impl ImageMounter {
match res.get("Status") {
Some(plist::Value::String(s)) => {
if s.as_str() != "ReceiveBytesAck" {
log::error!("Received bad response to SendBytes: {s:?}");
tracing::error!("Received bad response to SendBytes: {s:?}");
return Err(IdeviceError::UnexpectedResponse);
}
}
@@ -178,7 +178,7 @@ impl ImageMounter {
match res.get("Status") {
Some(plist::Value::String(s)) => {
if s.as_str() != "Complete" {
log::error!("Image send failure: {s:?}");
tracing::error!("Image send failure: {s:?}");
return Err(IdeviceError::UnexpectedResponse);
}
}
@@ -221,7 +221,7 @@ impl ImageMounter {
match res.get("Status") {
Some(plist::Value::String(s)) => {
if s.as_str() != "Complete" {
log::error!("Image send failure: {s:?}");
tracing::error!("Image send failure: {s:?}");
return Err(IdeviceError::UnexpectedResponse);
}
}
@@ -537,7 +537,7 @@ impl ImageMounter {
build_manifest: &plist::Dictionary,
unique_chip_id: u64,
) -> Result<Vec<u8>, IdeviceError> {
use log::{debug, warn};
use tracing::{debug, warn};
let mut request = TSSRequest::new();

View File

@@ -3,12 +3,12 @@
//! Provides functionality for interacting with the mobilebackup2 service on iOS devices,
//! which allows creating, restoring, and managing device backups.
use log::{debug, warn};
use plist::Dictionary;
use std::fs;
use std::io::{Read, Write};
use std::path::Path;
use tokio::io::AsyncReadExt;
use tracing::{debug, warn};
use crate::{Idevice, IdeviceError, IdeviceService, obf};

View File

@@ -44,11 +44,11 @@ impl PreboardServiceClient {
let res = self.idevice.read_plist().await?;
if let Some(res) = res.get("ShowDialog").and_then(|x| x.as_boolean()) {
if !res {
log::warn!("ShowDialog is not true");
tracing::warn!("ShowDialog is not true");
return Err(IdeviceError::UnexpectedResponse);
}
} else {
log::warn!("No ShowDialog in response from service");
tracing::warn!("No ShowDialog in response from service");
return Err(IdeviceError::UnexpectedResponse);
}

View File

@@ -1,7 +1,7 @@
//! Restore Service
use log::warn;
use plist::Dictionary;
use tracing::warn;
use crate::{IdeviceError, ReadWrite, RemoteXpcClient, RsdService, obf};

View File

@@ -3,8 +3,8 @@
use std::collections::HashMap;
use log::{debug, warn};
use serde::Deserialize;
use tracing::{debug, warn};
use crate::{IdeviceError, ReadWrite, RemoteXpcClient, provider::RsdProvider};

View File

@@ -4,9 +4,9 @@
//! which allows taking screenshots.
use crate::{Idevice, IdeviceError, IdeviceService, obf};
use log::{debug, warn};
use std::borrow::Cow;
use tokio::io::AsyncReadExt;
use tracing::{debug, warn};
pub struct ScreenshotService {
/// Underlying device connection
pub idevice: Idevice,

View File

@@ -62,11 +62,11 @@
use std::{collections::HashMap, io::ErrorKind, net::IpAddr, path::Path, sync::Arc};
use log::{debug, trace, warn};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
sync::Mutex,
};
use tracing::{debug, trace, warn};
use crate::{ReadWrite, tcp::packets::IpParseError};

View File

@@ -8,12 +8,12 @@ use std::{collections::HashMap, path::PathBuf, sync::Mutex, task::Poll};
use crossfire::{AsyncRx, MTx, Tx, mpsc, spsc, stream::AsyncStream};
use futures::{StreamExt, stream::FuturesUnordered};
use log::trace;
use tokio::{
io::{AsyncRead, AsyncWrite},
sync::oneshot,
time::timeout,
};
use tracing::trace;
use crate::tcp::adapter::ConnectionStatus;

View File

@@ -5,8 +5,8 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
use log::trace;
use tokio::io::AsyncWriteExt;
use tracing::trace;
use crate::{ReadWrite, provider::RsdProvider};
@@ -158,8 +158,6 @@ mod tests {
#[tokio::test]
async fn local_tcp() {
env_logger::init();
let our_ip = Ipv6Addr::from_str("fd12:3456:789a::1").unwrap();
let their_ip = Ipv6Addr::from_str("fd12:3456:789a::2").unwrap();
let dev = DeviceBuilder::new()

View File

@@ -6,11 +6,11 @@ use std::{
sync::Arc,
};
use log::debug;
use tokio::{
io::{AsyncRead, AsyncReadExt},
sync::Mutex,
};
use tracing::debug;
pub enum ProtocolNumber {
Tcp = 6,

View File

@@ -2,8 +2,8 @@
use std::{future::Future, task::Poll};
use log::trace;
use tokio::io::{AsyncRead, AsyncWrite};
use tracing::trace;
use crate::tcp::adapter::ConnectionStatus;

View File

@@ -5,8 +5,8 @@
//! - Apply restore request rules for device-specific parameters
//! - Handle cryptographic signing operations
use log::{debug, warn};
use plist::Value;
use tracing::{debug, warn};
use crate::{IdeviceError, util::plist_to_xml_bytes};

View File

@@ -5,9 +5,9 @@
use std::{collections::HashMap, net::SocketAddr};
use log::warn;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use tracing::warn;
use crate::IdeviceError;

View File

@@ -2,8 +2,8 @@
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use log::{debug, warn};
use serde::Deserialize;
use tracing::{debug, warn};
use crate::{
IdeviceError,

View File

@@ -13,8 +13,8 @@ use std::{
use std::net::{Ipv4Addr, SocketAddrV4};
use futures::Stream;
use log::{debug, warn};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tracing::{debug, warn};
use crate::{
Idevice, IdeviceError, ReadWrite, pairing_file::PairingFile, provider::UsbmuxdProvider,

View File

@@ -1,7 +1,7 @@
// Jackson Coxson
use crate::util::plist_to_xml_bytes;
use log::warn;
use tracing::warn;
#[derive(Debug)]
pub struct RawPacket {

View File

@@ -5,8 +5,8 @@ use std::{
};
use indexmap::IndexMap;
use log::{debug, warn};
use serde::{Deserialize, Serialize};
use tracing::{debug, warn};
use crate::IdeviceError;

View File

@@ -1,9 +1,9 @@
// Jackson Coxson
use frame::HttpFrame;
use log::{debug, warn};
use std::collections::{HashMap, VecDeque};
use tokio::io::AsyncWriteExt;
use tracing::{debug, warn};
use crate::{IdeviceError, ReadWrite};

View File

@@ -3,7 +3,7 @@
use async_stream::try_stream;
use futures::Stream;
use http2::Setting;
use log::debug;
use tracing::debug;
use crate::{IdeviceError, ReadWrite};