Skip to content

Commit 3a23670

Browse files
committed
Add more trace logging
1 parent 0cd929c commit 3a23670

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/devices.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,18 @@ impl SharedDevices {
222222
}
223223
}
224224
};
225-
let mac_addr = match plist.clone().dict_get_item("WiFiMACAddress") {
226-
Ok(item) => match item.get_string_val() {
227-
Ok(val) => val,
228-
Err(_) => {
229-
warn!("Could not get string value of WiFiMACAddress");
230-
continue;
225+
let wifi_plist = plist.clone();
226+
let mac_addr = match wifi_plist.dict_get_item("WiFiMACAddress") {
227+
Ok(item) => {
228+
log::debug!("WiFi plist item: {:?}", item.get_string_val());
229+
match item.get_string_val() {
230+
Ok(val) => val,
231+
Err(e) => {
232+
warn!("Could not get string value of WiFiMACAddress: {e:?}");
233+
continue;
234+
}
231235
}
232-
},
236+
}
233237
Err(_) => {
234238
warn!("Plist did not contain WiFiMACAddress");
235239
continue;

src/heartbeat.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn heartbeat(
2020
let pls_stop_clone = pls_stop.clone();
2121
tokio::task::spawn_blocking(move || {
2222
let device = idevice::Device::new(udid.clone(), Some(ip_addr), 0);
23+
log::debug!("Created device struct {udid}");
2324
let hb_client = match HeartbeatClient::new(&device, "netmuxd".to_string()) {
2425
Ok(hb_client) => hb_client,
2526
Err(e) => {
@@ -33,15 +34,18 @@ pub fn heartbeat(
3334
return;
3435
}
3536
};
37+
log::debug!("Created device heartbeat client for {udid}");
3638

3739
let mut heartbeat_tries = 0;
3840
loop {
3941
match hb_client.receive(10000) {
4042
Ok(plist) => match hb_client.send(plist) {
4143
Ok(_) => {
44+
log::debug!("Heartbeat recv {udid}");
4245
heartbeat_tries = 0;
4346
}
44-
Err(_) => {
47+
Err(e) => {
48+
info!("Heartbeat send failed for {}: {:?}", udid, e);
4549
tokio::spawn(async move {
4650
remove_from_data(data, udid).await;
4751
});
@@ -51,7 +55,7 @@ pub fn heartbeat(
5155
Err(e) => {
5256
heartbeat_tries += 1;
5357
if heartbeat_tries > 5 {
54-
info!("Heartbeat failed for {}: {:?}", udid, e);
58+
info!("Heartbeat recv failed for {}: {:?}", udid, e);
5559
tokio::spawn(async move {
5660
remove_from_data(data, udid).await;
5761
});

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{fs, os::unix::prelude::PermissionsExt};
66

77
use crate::raw_packet::RawPacket;
88
use devices::SharedDevices;
9-
use log::{error, info, warn};
9+
use log::{error, info, trace, warn};
1010
use plist_plus::Plist;
1111
use tokio::{
1212
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
@@ -199,14 +199,16 @@ async fn handle_stream(
199199
loop {
200200
// Wait for a message from the client
201201
let mut buf = [0; 1024];
202+
trace!("Waiting for data from client...");
202203
let size = match socket.read(&mut buf).await {
203204
Ok(s) => s,
204205
Err(_) => {
205206
return;
206207
}
207208
};
209+
trace!("Recv'd {size} bytes");
208210
if size == 0 {
209-
info!("Unix size is zero, closing connection");
211+
info!("Received size is zero, closing connection");
210212
return;
211213
}
212214

@@ -252,6 +254,8 @@ async fn handle_stream(
252254
.get_string_val()
253255
.unwrap();
254256

257+
trace!("usbmuxd client sent {packet_type}");
258+
255259
match packet_type.as_str() {
256260
//////////////////////////////
257261
// netmuxd specific packets //

0 commit comments

Comments
 (0)