mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Replace log crate with tracing
This commit is contained in:
@@ -47,7 +47,7 @@ pub unsafe extern "C" fn adapter_connect(
|
||||
null_mut()
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Adapter connect failed: {e}");
|
||||
tracing::error!("Adapter connect failed: {e}");
|
||||
ffi_err!(e)
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ pub unsafe extern "C" fn adapter_pcap(
|
||||
match res {
|
||||
Ok(_) => null_mut(),
|
||||
Err(e) => {
|
||||
log::error!("Adapter pcap failed: {e}");
|
||||
tracing::error!("Adapter pcap failed: {e}");
|
||||
ffi_err!(e)
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ pub unsafe extern "C" fn adapter_send(
|
||||
match res {
|
||||
Ok(_) => null_mut(),
|
||||
Err(e) => {
|
||||
log::error!("Adapter send failed: {e}");
|
||||
tracing::error!("Adapter send failed: {e}");
|
||||
ffi_err!(e)
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ pub unsafe extern "C" fn adapter_recv(
|
||||
null_mut()
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Adapter recv failed: {e}");
|
||||
tracing::error!("Adapter recv failed: {e}");
|
||||
ffi_err!(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn afc_client_connect(
|
||||
client: *mut *mut AfcClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ pub unsafe extern "C" fn afc_client_new(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn afc_client_free(handle: *mut AfcClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing afc_client");
|
||||
tracing::debug!("Freeing afc_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ pub unsafe extern "C" fn amfi_connect(
|
||||
client: *mut *mut AmfiClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ pub unsafe extern "C" fn amfi_accept_developer_mode(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn amfi_client_free(handle: *mut AmfiClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing AmfiClient handle");
|
||||
tracing::debug!("Freeing AmfiClient handle");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::ptr::null_mut;
|
||||
use futures::{Stream, StreamExt};
|
||||
use idevice::core_device::DiagnostisServiceClient;
|
||||
use idevice::{IdeviceError, ReadWrite, RsdService};
|
||||
use log::debug;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::core_device_proxy::AdapterHandle;
|
||||
use crate::rsd::RsdHandshakeHandle;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub unsafe extern "C" fn core_device_proxy_connect(
|
||||
client: *mut *mut CoreDeviceProxyHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ pub unsafe extern "C" fn core_device_proxy_get_client_parameters(
|
||||
netmask: *mut *mut c_char,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if handle.is_null() {
|
||||
log::error!("Passed null handle");
|
||||
tracing::error!("Passed null handle");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ pub unsafe extern "C" fn core_device_proxy_create_tcp_adapter(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn core_device_proxy_free(handle: *mut CoreDeviceProxyHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing core_device_proxy");
|
||||
tracing::debug!("Freeing core_device_proxy");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
@@ -349,7 +349,7 @@ pub unsafe extern "C" fn core_device_proxy_free(handle: *mut CoreDeviceProxyHand
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn adapter_free(handle: *mut AdapterHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing adapter");
|
||||
tracing::debug!("Freeing adapter");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub unsafe extern "C" fn heartbeat_connect(
|
||||
client: *mut *mut HeartbeatClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ pub unsafe extern "C" fn heartbeat_get_marco(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn heartbeat_client_free(handle: *mut HeartbeatClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing installation_proxy_client");
|
||||
tracing::debug!("Freeing installation_proxy_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn installation_proxy_connect(
|
||||
client: *mut *mut InstallationProxyClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ pub unsafe extern "C" fn installation_proxy_get_apps(
|
||||
out_result_len: *mut libc::size_t,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if client.is_null() || out_result.is_null() || out_result_len.is_null() {
|
||||
log::error!("Invalid arguments: {client:?}, {out_result:?}");
|
||||
tracing::error!("Invalid arguments: {client:?}, {out_result:?}");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
let client = unsafe { &mut *client };
|
||||
@@ -171,7 +171,7 @@ pub unsafe extern "C" fn installation_proxy_client_free(
|
||||
handle: *mut InstallationProxyClientHandle,
|
||||
) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing installation_proxy_client");
|
||||
tracing::debug!("Freeing installation_proxy_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ pub unsafe extern "C" fn idevice_new_tcp_socket(
|
||||
use crate::util::SockAddr;
|
||||
|
||||
if addr.is_null() || label.is_null() || idevice.is_null() {
|
||||
log::error!("null pointer(s) to idevice_new_tcp_socket");
|
||||
tracing::error!("null pointer(s) to idevice_new_tcp_socket");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
let addr = addr as *const SockAddr;
|
||||
|
||||
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn lockdownd_connect(
|
||||
client: *mut *mut LockdowndClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ pub unsafe extern "C" fn lockdownd_get_value(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn lockdownd_client_free(handle: *mut LockdowndClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing lockdownd_client");
|
||||
tracing::debug!("Freeing lockdownd_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,75 +3,12 @@
|
||||
use std::{
|
||||
ffi::{CStr, c_char},
|
||||
fs::File,
|
||||
sync::Once,
|
||||
};
|
||||
|
||||
use log::LevelFilter;
|
||||
use simplelog::{
|
||||
ColorChoice, CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode, WriteLogger,
|
||||
};
|
||||
|
||||
/// Initializes the logger
|
||||
///
|
||||
/// # Arguments
|
||||
/// * [`console_level`] - The level to log to the file
|
||||
/// * [`file_level`] - The level to log to the file
|
||||
/// * [`file_path`] - If not null, the file to write logs to
|
||||
///
|
||||
/// ## Log Level
|
||||
/// 0. Disabled
|
||||
/// 1. Error
|
||||
/// 2. Warn
|
||||
/// 3. Info
|
||||
/// 4. Debug
|
||||
/// 5. Trace
|
||||
///
|
||||
/// # Returns
|
||||
/// 0 for success, -1 if the file couldn't be created, -2 if a logger has been initialized, -3 for invalid path string
|
||||
///
|
||||
/// # Safety
|
||||
/// Pass a valid CString for file_path. Pass valid log levels according to the enum
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn idevice_init_logger(
|
||||
console_level: IdeviceLogLevel,
|
||||
file_level: IdeviceLogLevel,
|
||||
file_path: *mut c_char,
|
||||
) -> IdeviceLoggerError {
|
||||
let mut loggers: Vec<Box<dyn SharedLogger>> = Vec::new();
|
||||
let level: LevelFilter = console_level.into();
|
||||
loggers.push(TermLogger::new(
|
||||
level,
|
||||
Config::default(),
|
||||
TerminalMode::Mixed,
|
||||
ColorChoice::Auto,
|
||||
));
|
||||
|
||||
if !file_path.is_null() {
|
||||
let file_path = match unsafe { CStr::from_ptr(file_path) }.to_str() {
|
||||
Ok(f) => f.to_string(),
|
||||
Err(_) => {
|
||||
return IdeviceLoggerError::InvalidPathString;
|
||||
}
|
||||
};
|
||||
let level: LevelFilter = file_level.into();
|
||||
loggers.push(WriteLogger::new(
|
||||
level,
|
||||
Config::default(),
|
||||
match File::create(file_path) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
println!("Failed to create path: {e:?}");
|
||||
return IdeviceLoggerError::FileError;
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
if CombinedLogger::init(loggers).is_err() {
|
||||
IdeviceLoggerError::AlreadyInitialized
|
||||
} else {
|
||||
IdeviceLoggerError::Success
|
||||
}
|
||||
}
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::{EnvFilter, Layer, fmt::writer::BoxMakeWriter};
|
||||
use tracing_subscriber::{Registry, fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
#[repr(C)]
|
||||
pub enum IdeviceLoggerError {
|
||||
@@ -92,33 +29,99 @@ pub enum IdeviceLogLevel {
|
||||
Trace = 5,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for IdeviceLogLevel {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||
Ok(match value {
|
||||
0 => Self::Disabled,
|
||||
1 => Self::ErrorLevel,
|
||||
2 => Self::Warn,
|
||||
3 => Self::Info,
|
||||
4 => Self::Debug,
|
||||
5 => Self::Trace,
|
||||
_ => {
|
||||
return Err(());
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IdeviceLogLevel> for LevelFilter {
|
||||
impl From<IdeviceLogLevel> for Level {
|
||||
fn from(value: IdeviceLogLevel) -> Self {
|
||||
match value {
|
||||
IdeviceLogLevel::Disabled => LevelFilter::Off,
|
||||
IdeviceLogLevel::ErrorLevel => LevelFilter::Error,
|
||||
IdeviceLogLevel::Warn => LevelFilter::Warn,
|
||||
IdeviceLogLevel::Info => LevelFilter::Info,
|
||||
IdeviceLogLevel::Debug => LevelFilter::Debug,
|
||||
IdeviceLogLevel::Trace => LevelFilter::Trace,
|
||||
IdeviceLogLevel::Disabled => Level::ERROR, // won't matter, filter will disable
|
||||
IdeviceLogLevel::ErrorLevel => Level::ERROR,
|
||||
IdeviceLogLevel::Warn => Level::WARN,
|
||||
IdeviceLogLevel::Info => Level::INFO,
|
||||
IdeviceLogLevel::Debug => Level::DEBUG,
|
||||
IdeviceLogLevel::Trace => Level::TRACE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IdeviceLogLevel {
|
||||
fn as_filter(&self) -> String {
|
||||
match self {
|
||||
IdeviceLogLevel::Disabled => "off",
|
||||
IdeviceLogLevel::ErrorLevel => "error",
|
||||
IdeviceLogLevel::Warn => "warn",
|
||||
IdeviceLogLevel::Info => "info",
|
||||
IdeviceLogLevel::Debug => "debug",
|
||||
IdeviceLogLevel::Trace => "trace",
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
// ensures we only init once
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
/// Initializes the global logger
|
||||
///
|
||||
/// # Safety
|
||||
/// Pass a valid file path string
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn idevice_init_logger(
|
||||
console_level: IdeviceLogLevel,
|
||||
file_level: IdeviceLogLevel,
|
||||
file_path: *mut c_char,
|
||||
) -> IdeviceLoggerError {
|
||||
let mut init_result = IdeviceLoggerError::Success;
|
||||
|
||||
INIT.call_once(|| {
|
||||
let console_filter = console_level.as_filter();
|
||||
let file_filter = file_level.as_filter();
|
||||
|
||||
let mut layers = Vec::new();
|
||||
|
||||
// Console layer
|
||||
if console_level != IdeviceLogLevel::Disabled {
|
||||
let console_layer = fmt::layer()
|
||||
.with_writer(std::io::stdout)
|
||||
.with_ansi(true)
|
||||
.with_target(false)
|
||||
.with_filter(EnvFilter::new(console_filter));
|
||||
layers.push(console_layer.boxed());
|
||||
}
|
||||
|
||||
// File layer
|
||||
if !file_path.is_null() && file_level != IdeviceLogLevel::Disabled {
|
||||
let path = match unsafe { CStr::from_ptr(file_path).to_str() } {
|
||||
Ok(p) => p,
|
||||
Err(_) => {
|
||||
init_result = IdeviceLoggerError::InvalidPathString;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let file = match File::create(path) {
|
||||
Ok(f) => f,
|
||||
Err(_) => {
|
||||
init_result = IdeviceLoggerError::FileError;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let file_layer = fmt::layer()
|
||||
.with_writer(BoxMakeWriter::new(file))
|
||||
.with_ansi(false)
|
||||
.with_target(false)
|
||||
.with_filter(EnvFilter::new(file_filter));
|
||||
layers.push(file_layer.boxed());
|
||||
}
|
||||
|
||||
// Compose and set as global subscriber
|
||||
let subscriber = Registry::default().with(layers);
|
||||
subscriber.init();
|
||||
});
|
||||
|
||||
// If it was already initialized, Once won't run again
|
||||
if !INIT.is_completed() {
|
||||
IdeviceLoggerError::AlreadyInitialized
|
||||
} else {
|
||||
init_result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub unsafe extern "C" fn misagent_connect(
|
||||
client: *mut *mut MisagentClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ pub unsafe extern "C" fn misagent_free_profiles(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn misagent_client_free(handle: *mut MisagentClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing misagent_client");
|
||||
tracing::debug!("Freeing misagent_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn image_mounter_connect(
|
||||
client: *mut *mut ImageMounterHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ pub unsafe extern "C" fn image_mounter_new(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn image_mounter_free(handle: *mut ImageMounterHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing image_mounter_client");
|
||||
tracing::debug!("Freeing image_mounter_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ pub unsafe extern "C" fn os_trace_relay_connect(
|
||||
client: *mut *mut OsTraceRelayClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ pub unsafe extern "C" fn os_trace_relay_connect(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn os_trace_relay_free(handle: *mut OsTraceRelayClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing os trace relay client");
|
||||
tracing::debug!("Freeing os trace relay client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ pub unsafe extern "C" fn os_trace_relay_start_trace(
|
||||
pid: *const u32,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if receiver.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ pub unsafe extern "C" fn os_trace_relay_start_trace(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn os_trace_relay_receiver_free(handle: *mut OsTraceRelayReceiverHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing syslog relay client");
|
||||
tracing::debug!("Freeing syslog relay client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ pub unsafe extern "C" fn os_trace_relay_next(
|
||||
log: *mut *mut OsTraceLog,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ pub unsafe extern "C" fn idevice_pairing_file_serialize(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn idevice_pairing_file_free(pairing_file: *mut IdevicePairingFile) {
|
||||
if !pairing_file.is_null() {
|
||||
log::debug!("Freeing pairing file");
|
||||
tracing::debug!("Freeing pairing file");
|
||||
let _ = unsafe { Box::from_raw(pairing_file) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ pub unsafe extern "C" fn idevice_tcp_provider_new(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn idevice_provider_free(provider: *mut IdeviceProviderHandle) {
|
||||
if !provider.is_null() {
|
||||
log::debug!("Freeing provider");
|
||||
tracing::debug!("Freeing provider");
|
||||
unsafe { drop(Box::from_raw(provider)) };
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ pub unsafe extern "C" fn usbmuxd_provider_new(
|
||||
let udid = match unsafe { CStr::from_ptr(udid) }.to_str() {
|
||||
Ok(u) => u.to_string(),
|
||||
Err(e) => {
|
||||
log::error!("Invalid UDID string: {e:?}");
|
||||
tracing::error!("Invalid UDID string: {e:?}");
|
||||
return ffi_err!(IdeviceError::FfiInvalidString);
|
||||
}
|
||||
};
|
||||
@@ -117,7 +117,7 @@ pub unsafe extern "C" fn usbmuxd_provider_new(
|
||||
let label = match unsafe { CStr::from_ptr(label) }.to_str() {
|
||||
Ok(l) => l.to_string(),
|
||||
Err(e) => {
|
||||
log::error!("Invalid label string: {e:?}");
|
||||
tracing::error!("Invalid label string: {e:?}");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn springboard_services_connect(
|
||||
client: *mut *mut SpringBoardServicesClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() || client.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ pub unsafe extern "C" fn springboard_services_get_icon(
|
||||
out_result_len: *mut libc::size_t,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if client.is_null() || out_result.is_null() || out_result_len.is_null() {
|
||||
log::error!("Invalid arguments: {client:?}, {out_result:?}");
|
||||
tracing::error!("Invalid arguments: {client:?}, {out_result:?}");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
let client = unsafe { &mut *client };
|
||||
@@ -145,7 +145,7 @@ pub unsafe extern "C" fn springboard_services_get_icon(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn springboard_services_free(handle: *mut SpringBoardServicesClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing springboard_services_client");
|
||||
tracing::debug!("Freeing springboard_services_client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub unsafe extern "C" fn syslog_relay_connect_tcp(
|
||||
client: *mut *mut SyslogRelayClientHandle,
|
||||
) -> *mut IdeviceFfiError {
|
||||
if provider.is_null() {
|
||||
log::error!("Null pointer provided");
|
||||
tracing::error!("Null pointer provided");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ pub unsafe extern "C" fn syslog_relay_connect_tcp(
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn syslog_relay_client_free(handle: *mut SyslogRelayClientHandle) {
|
||||
if !handle.is_null() {
|
||||
log::debug!("Freeing syslog relay client");
|
||||
tracing::debug!("Freeing syslog relay client");
|
||||
let _ = unsafe { Box::from_raw(handle) };
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ pub unsafe extern "C" fn syslog_relay_next(
|
||||
null_mut()
|
||||
}
|
||||
Err(_) => {
|
||||
log::error!("Failed to convert log message to C string");
|
||||
tracing::error!("Failed to convert log message to C string");
|
||||
ffi_err!(IdeviceError::FfiInvalidString)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use idevice::{
|
||||
IdeviceError,
|
||||
usbmuxd::{UsbmuxdAddr, UsbmuxdConnection, UsbmuxdDevice, UsbmuxdListenEvent},
|
||||
};
|
||||
use log::error;
|
||||
use tracing::error;
|
||||
|
||||
pub struct UsbmuxdConnectionHandle(pub UsbmuxdConnection);
|
||||
pub struct UsbmuxdAddrHandle(pub UsbmuxdAddr);
|
||||
@@ -132,7 +132,7 @@ pub unsafe extern "C" fn idevice_usbmuxd_new_default_connection(
|
||||
let addr = match UsbmuxdAddr::from_env_var() {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
log::error!("Invalid address set: {e:?}");
|
||||
tracing::error!("Invalid address set: {e:?}");
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
addr_len: SockLen,
|
||||
) -> Result<SocketAddr, IdeviceError> {
|
||||
if addr.is_null() {
|
||||
log::error!("null sockaddr");
|
||||
tracing::error!("null sockaddr");
|
||||
return invalid_arg();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
match family as i32 {
|
||||
libc::AF_INET => {
|
||||
if (addr_len as usize) < std::mem::size_of::<sockaddr_in>() {
|
||||
log::error!("Invalid sockaddr_in size");
|
||||
tracing::error!("Invalid sockaddr_in size");
|
||||
return invalid_arg();
|
||||
}
|
||||
let a = &*(addr as *const sockaddr_in);
|
||||
@@ -69,7 +69,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
}
|
||||
libc::AF_INET6 => {
|
||||
if (addr_len as usize) < std::mem::size_of::<sockaddr_in6>() {
|
||||
log::error!("Invalid sockaddr_in6 size");
|
||||
tracing::error!("Invalid sockaddr_in6 size");
|
||||
return invalid_arg();
|
||||
}
|
||||
let a = &*(addr as *const sockaddr_in6);
|
||||
@@ -83,7 +83,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
)))
|
||||
}
|
||||
_ => {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Unsupported socket address family: {}",
|
||||
(*addr).sa_family as i32
|
||||
);
|
||||
@@ -95,7 +95,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
match family {
|
||||
AF_INET => {
|
||||
if (addr_len as usize) < std::mem::size_of::<sockaddr_in>() {
|
||||
log::error!("Invalid SOCKADDR_IN size");
|
||||
tracing::error!("Invalid SOCKADDR_IN size");
|
||||
return invalid_arg();
|
||||
}
|
||||
let a = &*(addr as *const sockaddr_in);
|
||||
@@ -107,7 +107,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
}
|
||||
AF_INET6 => {
|
||||
if (addr_len as usize) < std::mem::size_of::<sockaddr_in6>() {
|
||||
log::error!("Invalid SOCKADDR_IN6 size");
|
||||
tracing::error!("Invalid SOCKADDR_IN6 size");
|
||||
return invalid_arg();
|
||||
}
|
||||
let a = &*(addr as *const sockaddr_in6);
|
||||
@@ -124,7 +124,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
)))
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unsupported socket address family: {}", (*addr).sa_family);
|
||||
tracing::error!("Unsupported socket address family: {}", (*addr).sa_family);
|
||||
invalid_arg()
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ pub(crate) fn c_socket_to_rust(
|
||||
|
||||
pub(crate) fn c_addr_to_rust(addr: *const SockAddr) -> Result<IpAddr, IdeviceError> {
|
||||
if addr.is_null() {
|
||||
log::error!("null sockaddr");
|
||||
tracing::error!("null sockaddr");
|
||||
return invalid_arg();
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ pub(crate) fn c_addr_to_rust(addr: *const SockAddr) -> Result<IpAddr, IdeviceErr
|
||||
Ok(IpAddr::V6(Ipv6Addr::from(a.sin6_addr.s6_addr)))
|
||||
}
|
||||
_ => {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Unsupported socket address family: {}",
|
||||
(*addr).sa_family as i32
|
||||
);
|
||||
@@ -178,7 +178,7 @@ pub(crate) fn c_addr_to_rust(addr: *const SockAddr) -> Result<IpAddr, IdeviceErr
|
||||
Ok(IpAddr::V6(Ipv6Addr::from(bytes)))
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unsupported socket address family: {}", (*addr).sa_family);
|
||||
tracing::error!("Unsupported socket address family: {}", (*addr).sa_family);
|
||||
invalid_arg()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user