summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2020-06-08 03:01:18 +0200
committerGravatar Martin Szulecki2020-06-08 03:01:18 +0200
commit7317958e0c8f52bca6fd4deee1045d117e1b0619 (patch)
tree6a4b5b7f700c781b0a12c700e1546429daf139b1 /src
parentea94e4c05360872cb9050b3f39299778d8621c20 (diff)
downloadusbmuxd-7317958e0c8f52bca6fd4deee1045d117e1b0619.tar.gz
usbmuxd-7317958e0c8f52bca6fd4deee1045d117e1b0619.tar.bz2
Improve and unify log message output for client, device and config
Diffstat (limited to 'src')
-rw-r--r--src/client.c10
-rw-r--r--src/conf.c22
-rw-r--r--src/device.c6
3 files changed, 19 insertions, 19 deletions
diff --git a/src/client.c b/src/client.c
index 1588c38..1fc15c8 100644
--- a/src/client.c
+++ b/src/client.c
@@ -300,7 +300,7 @@ static int send_pkt(struct mux_client *client, uint32_t tag, enum usbmuxd_msgtyp
300 hdr.length = sizeof(hdr) + payload_length; 300 hdr.length = sizeof(hdr) + payload_length;
301 hdr.message = msg; 301 hdr.message = msg;
302 hdr.tag = tag; 302 hdr.tag = tag;
303 usbmuxd_log(LL_DEBUG, "send_pkt fd %d tag %d msg %d payload_length %d", client->fd, tag, msg, payload_length); 303 usbmuxd_log(LL_DEBUG, "Client %d output buffer got tag %d msg %d payload_length %d", client->fd, tag, msg, payload_length);
304 304
305 uint32_t available = client->ob_capacity - client->ob_size; 305 uint32_t available = client->ob_capacity - client->ob_size;
306 /* the output buffer _should_ be large enough, but just in case */ 306 /* the output buffer _should_ be large enough, but just in case */
@@ -646,10 +646,10 @@ static void update_client_info(struct mux_client *client, plist_t dict)
646static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) 646static int client_command(struct mux_client *client, struct usbmuxd_header *hdr)
647{ 647{
648 int res; 648 int res;
649 usbmuxd_log(LL_DEBUG, "Client command in fd %d len %d ver %d msg %d tag %d", client->fd, hdr->length, hdr->version, hdr->message, hdr->tag); 649 usbmuxd_log(LL_DEBUG, "Client %d command len %d ver %d msg %d tag %d", client->fd, hdr->length, hdr->version, hdr->message, hdr->tag);
650 650
651 if(client->state != CLIENT_COMMAND) { 651 if(client->state != CLIENT_COMMAND) {
652 usbmuxd_log(LL_ERROR, "Client %d command received in the wrong state", client->fd); 652 usbmuxd_log(LL_ERROR, "Client %d command received in the wrong state, got %d but want %d", client->fd, client->state, CLIENT_COMMAND);
653 if(send_result(client, hdr->tag, RESULT_BADCOMMAND) < 0) 653 if(send_result(client, hdr->tag, RESULT_BADCOMMAND) < 0)
654 return -1; 654 return -1;
655 client_close(client); 655 client_close(client);
@@ -730,7 +730,7 @@ static int client_command(struct mux_client *client, struct usbmuxd_header *hdr)
730 portnum = (uint16_t)val; 730 portnum = (uint16_t)val;
731 plist_free(dict); 731 plist_free(dict);
732 732
733 usbmuxd_log(LL_DEBUG, "Client %d connection request to device %d port %d", client->fd, device_id, ntohs(portnum)); 733 usbmuxd_log(LL_DEBUG, "Client %d requesting connection to device %d port %d", client->fd, device_id, ntohs(portnum));
734 res = device_start_connect(device_id, ntohs(portnum), client); 734 res = device_start_connect(device_id, ntohs(portnum), client);
735 if(res < 0) { 735 if(res < 0) {
736 if (send_result(client, hdr->tag, -res) < 0) 736 if (send_result(client, hdr->tag, -res) < 0)
@@ -888,7 +888,7 @@ static void process_send(struct mux_client *client)
888 } 888 }
889 res = send(client->fd, client->ob_buf, client->ob_size, 0); 889 res = send(client->fd, client->ob_buf, client->ob_size, 0);
890 if(res <= 0) { 890 if(res <= 0) {
891 usbmuxd_log(LL_ERROR, "Send to client fd %d failed: %d %s", client->fd, res, strerror(errno)); 891 usbmuxd_log(LL_ERROR, "Sending to client fd %d failed: %d %s", client->fd, res, strerror(errno));
892 client_close(client); 892 client_close(client);
893 return; 893 return;
894 } 894 }
diff --git a/src/conf.c b/src/conf.c
index f211d99..db88e90 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -140,7 +140,7 @@ const char *config_get_config_dir()
140 140
141 free(base_config_dir); 141 free(base_config_dir);
142 142
143 usbmuxd_log(LL_DEBUG, "initialized config_dir to %s", __config_dir); 143 usbmuxd_log(LL_DEBUG, "Initialized config_dir to %s", __config_dir);
144 144
145 return __config_dir; 145 return __config_dir;
146} 146}
@@ -247,11 +247,11 @@ static int internal_set_value(const char *config_file, const char *key, plist_t
247 char *value_string = NULL; 247 char *value_string = NULL;
248 if (plist_get_node_type(value) == PLIST_STRING) { 248 if (plist_get_node_type(value) == PLIST_STRING) {
249 plist_get_string_val(value, &value_string); 249 plist_get_string_val(value, &value_string);
250 usbmuxd_log(LL_DEBUG, "setting key %s to %s in config_file %s", key, value_string, config_file); 250 usbmuxd_log(LL_DEBUG, "Setting key %s to %s in config file %s", key, value_string, config_file);
251 if (value_string) 251 if (value_string)
252 free(value_string); 252 free(value_string);
253 } else { 253 } else {
254 usbmuxd_log(LL_DEBUG, "setting key %s in config_file %s", key, config_file); 254 usbmuxd_log(LL_DEBUG, "Setting key %s in config file %s", key, config_file);
255 } 255 }
256 256
257 int res = plist_write_to_filename(config, config_file, PLIST_FORMAT_XML); 257 int res = plist_write_to_filename(config, config_file, PLIST_FORMAT_XML);
@@ -289,7 +289,7 @@ static int internal_get_value(const char* config_file, const char *key, plist_t
289 /* now parse file to get the SystemBUID */ 289 /* now parse file to get the SystemBUID */
290 plist_t config = NULL; 290 plist_t config = NULL;
291 if (plist_read_from_filename(&config, config_file)) { 291 if (plist_read_from_filename(&config, config_file)) {
292 usbmuxd_log(LL_DEBUG, "reading key %s from config_file %s", key, config_file); 292 usbmuxd_log(LL_DEBUG, "Reading key %s from config file %s", key, config_file);
293 plist_t n = plist_dict_get_item(config, key); 293 plist_t n = plist_dict_get_item(config, key);
294 if (n) { 294 if (n) {
295 *value = plist_copy(n); 295 *value = plist_copy(n);
@@ -371,7 +371,7 @@ void config_get_system_buid(char **system_buid)
371 371
372 if (value && (plist_get_node_type(value) == PLIST_STRING)) { 372 if (value && (plist_get_node_type(value) == PLIST_STRING)) {
373 plist_get_string_val(value, system_buid); 373 plist_get_string_val(value, system_buid);
374 usbmuxd_log(LL_DEBUG, "got %s %s", CONFIG_SYSTEM_BUID_KEY, *system_buid); 374 usbmuxd_log(LL_DEBUG, "Got %s %s", CONFIG_SYSTEM_BUID_KEY, *system_buid);
375 } 375 }
376 376
377 if (value) 377 if (value)
@@ -379,14 +379,14 @@ void config_get_system_buid(char **system_buid)
379 379
380 if (!*system_buid) { 380 if (!*system_buid) {
381 /* no config, generate system_buid */ 381 /* no config, generate system_buid */
382 usbmuxd_log(LL_DEBUG, "no previous %s found", CONFIG_SYSTEM_BUID_KEY); 382 usbmuxd_log(LL_DEBUG, "No previous %s found", CONFIG_SYSTEM_BUID_KEY);
383 *system_buid = config_generate_system_buid(); 383 *system_buid = config_generate_system_buid();
384 if (!config_set_system_buid(*system_buid)) { 384 if (!config_set_system_buid(*system_buid)) {
385 usbmuxd_log(LL_WARNING, "WARNING: Failed to store SystemBUID, this might be a problem"); 385 usbmuxd_log(LL_WARNING, "WARNING: Failed to store SystemBUID, this might be a problem");
386 } 386 }
387 } 387 }
388 388
389 usbmuxd_log(LL_DEBUG, "using %s as %s", *system_buid, CONFIG_SYSTEM_BUID_KEY); 389 usbmuxd_log(LL_DEBUG, "Using %s as %s", *system_buid, CONFIG_SYSTEM_BUID_KEY);
390} 390}
391 391
392/** 392/**
@@ -429,7 +429,7 @@ int config_set_device_record(const char *udid, char* record_data, uint64_t recor
429 429
430 /* store file */ 430 /* store file */
431 if (!plist_write_to_filename(plist, device_record_file, PLIST_FORMAT_XML)) { 431 if (!plist_write_to_filename(plist, device_record_file, PLIST_FORMAT_XML)) {
432 usbmuxd_log(LL_DEBUG, "could not open '%s' for writing: %s", device_record_file, strerror(errno)); 432 usbmuxd_log(LL_DEBUG, "Could not open '%s' for writing: %s", device_record_file, strerror(errno));
433 res = -ENOENT; 433 res = -ENOENT;
434 } 434 }
435 free(device_record_file); 435 free(device_record_file);
@@ -464,7 +464,7 @@ int config_get_device_record(const char *udid, char **record_data, uint64_t *rec
464 /* read file */ 464 /* read file */
465 buffer_read_from_filename(device_record_file, record_data, record_size); 465 buffer_read_from_filename(device_record_file, record_data, record_size);
466 if (!*record_data) { 466 if (!*record_data) {
467 usbmuxd_log(LL_ERROR, "%s: failed to read '%s': %s", __func__, device_record_file, strerror(errno)); 467 usbmuxd_log(LL_ERROR, "ERROR: Failed to read '%s': %s", device_record_file, strerror(errno));
468 res = -ENOENT; 468 res = -ENOENT;
469 } 469 }
470 free(device_record_file); 470 free(device_record_file);
@@ -490,7 +490,7 @@ int config_remove_device_record(const char *udid)
490 /* remove file */ 490 /* remove file */
491 if (remove(device_record_file) != 0) { 491 if (remove(device_record_file) != 0) {
492 res = -errno; 492 res = -errno;
493 usbmuxd_log(LL_DEBUG, "could not remove %s: %s", device_record_file, strerror(errno)); 493 usbmuxd_log(LL_DEBUG, "Could not remove %s: %s", device_record_file, strerror(errno));
494 } 494 }
495 495
496 free(device_record_file); 496 free(device_record_file);
@@ -527,6 +527,6 @@ void config_device_record_get_host_id(const char *udid, char **host_id)
527 plist_free(value); 527 plist_free(value);
528 528
529 if (!*host_id) { 529 if (!*host_id) {
530 usbmuxd_log(LL_ERROR, "%s: ERROR couldn't get HostID from pairing record for udid %s", __func__, udid); 530 usbmuxd_log(LL_ERROR, "ERROR: Could not get HostID from pairing record for udid %s", udid);
531 } 531 }
532} 532}
diff --git a/src/device.c b/src/device.c
index 64e4e8d..ec65f87 100644
--- a/src/device.c
+++ b/src/device.c
@@ -598,10 +598,10 @@ static void device_control_input(struct mux_device *dev, unsigned char *payload,
598 char* buf = malloc(payload_length); 598 char* buf = malloc(payload_length);
599 strncpy(buf, (char*)payload+1, payload_length-1); 599 strncpy(buf, (char*)payload+1, payload_length-1);
600 buf[payload_length-1] = '\0'; 600 buf[payload_length-1] = '\0';
601 usbmuxd_log(LL_ERROR, "%s: ERROR: %s", __func__, buf); 601 usbmuxd_log(LL_ERROR, "%s: ERROR (on device): %s", __func__, buf);
602 free(buf); 602 free(buf);
603 } else { 603 } else {
604 usbmuxd_log(LL_ERROR, "%s: Error occurred, but empty error message", __func__); 604 usbmuxd_log(LL_ERROR, "%s: Got device error payload with empty message", __func__);
605 } 605 }
606 break; 606 break;
607 case 7: 607 case 7:
@@ -617,7 +617,7 @@ static void device_control_input(struct mux_device *dev, unsigned char *payload,
617 break; 617 break;
618 } 618 }
619 } else { 619 } else {
620 usbmuxd_log(LL_WARNING, "%s: got a type 1 packet without payload", __func__); 620 usbmuxd_log(LL_WARNING, "%s: Got a type 1 packet without payload", __func__);
621 } 621 }
622} 622}
623 623