From 7317958e0c8f52bca6fd4deee1045d117e1b0619 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Mon, 8 Jun 2020 03:01:18 +0200 Subject: Improve and unify log message output for client, device and config --- src/client.c | 10 +++++----- src/conf.c | 22 +++++++++++----------- src/device.c | 6 +++--- 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 hdr.length = sizeof(hdr) + payload_length; hdr.message = msg; hdr.tag = tag; - usbmuxd_log(LL_DEBUG, "send_pkt fd %d tag %d msg %d payload_length %d", client->fd, tag, msg, payload_length); + usbmuxd_log(LL_DEBUG, "Client %d output buffer got tag %d msg %d payload_length %d", client->fd, tag, msg, payload_length); uint32_t available = client->ob_capacity - client->ob_size; /* 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) static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) { int res; - 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); + 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); if(client->state != CLIENT_COMMAND) { - usbmuxd_log(LL_ERROR, "Client %d command received in the wrong state", client->fd); + usbmuxd_log(LL_ERROR, "Client %d command received in the wrong state, got %d but want %d", client->fd, client->state, CLIENT_COMMAND); if(send_result(client, hdr->tag, RESULT_BADCOMMAND) < 0) return -1; client_close(client); @@ -730,7 +730,7 @@ static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) portnum = (uint16_t)val; plist_free(dict); - usbmuxd_log(LL_DEBUG, "Client %d connection request to device %d port %d", client->fd, device_id, ntohs(portnum)); + usbmuxd_log(LL_DEBUG, "Client %d requesting connection to device %d port %d", client->fd, device_id, ntohs(portnum)); res = device_start_connect(device_id, ntohs(portnum), client); if(res < 0) { if (send_result(client, hdr->tag, -res) < 0) @@ -888,7 +888,7 @@ static void process_send(struct mux_client *client) } res = send(client->fd, client->ob_buf, client->ob_size, 0); if(res <= 0) { - usbmuxd_log(LL_ERROR, "Send to client fd %d failed: %d %s", client->fd, res, strerror(errno)); + usbmuxd_log(LL_ERROR, "Sending to client fd %d failed: %d %s", client->fd, res, strerror(errno)); client_close(client); return; } 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() free(base_config_dir); - usbmuxd_log(LL_DEBUG, "initialized config_dir to %s", __config_dir); + usbmuxd_log(LL_DEBUG, "Initialized config_dir to %s", __config_dir); return __config_dir; } @@ -247,11 +247,11 @@ static int internal_set_value(const char *config_file, const char *key, plist_t char *value_string = NULL; if (plist_get_node_type(value) == PLIST_STRING) { plist_get_string_val(value, &value_string); - usbmuxd_log(LL_DEBUG, "setting key %s to %s in config_file %s", key, value_string, config_file); + usbmuxd_log(LL_DEBUG, "Setting key %s to %s in config file %s", key, value_string, config_file); if (value_string) free(value_string); } else { - usbmuxd_log(LL_DEBUG, "setting key %s in config_file %s", key, config_file); + usbmuxd_log(LL_DEBUG, "Setting key %s in config file %s", key, config_file); } 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 /* now parse file to get the SystemBUID */ plist_t config = NULL; if (plist_read_from_filename(&config, config_file)) { - usbmuxd_log(LL_DEBUG, "reading key %s from config_file %s", key, config_file); + usbmuxd_log(LL_DEBUG, "Reading key %s from config file %s", key, config_file); plist_t n = plist_dict_get_item(config, key); if (n) { *value = plist_copy(n); @@ -371,7 +371,7 @@ void config_get_system_buid(char **system_buid) if (value && (plist_get_node_type(value) == PLIST_STRING)) { plist_get_string_val(value, system_buid); - usbmuxd_log(LL_DEBUG, "got %s %s", CONFIG_SYSTEM_BUID_KEY, *system_buid); + usbmuxd_log(LL_DEBUG, "Got %s %s", CONFIG_SYSTEM_BUID_KEY, *system_buid); } if (value) @@ -379,14 +379,14 @@ void config_get_system_buid(char **system_buid) if (!*system_buid) { /* no config, generate system_buid */ - usbmuxd_log(LL_DEBUG, "no previous %s found", CONFIG_SYSTEM_BUID_KEY); + usbmuxd_log(LL_DEBUG, "No previous %s found", CONFIG_SYSTEM_BUID_KEY); *system_buid = config_generate_system_buid(); if (!config_set_system_buid(*system_buid)) { usbmuxd_log(LL_WARNING, "WARNING: Failed to store SystemBUID, this might be a problem"); } } - usbmuxd_log(LL_DEBUG, "using %s as %s", *system_buid, CONFIG_SYSTEM_BUID_KEY); + usbmuxd_log(LL_DEBUG, "Using %s as %s", *system_buid, CONFIG_SYSTEM_BUID_KEY); } /** @@ -429,7 +429,7 @@ int config_set_device_record(const char *udid, char* record_data, uint64_t recor /* store file */ if (!plist_write_to_filename(plist, device_record_file, PLIST_FORMAT_XML)) { - usbmuxd_log(LL_DEBUG, "could not open '%s' for writing: %s", device_record_file, strerror(errno)); + usbmuxd_log(LL_DEBUG, "Could not open '%s' for writing: %s", device_record_file, strerror(errno)); res = -ENOENT; } free(device_record_file); @@ -464,7 +464,7 @@ int config_get_device_record(const char *udid, char **record_data, uint64_t *rec /* read file */ buffer_read_from_filename(device_record_file, record_data, record_size); if (!*record_data) { - usbmuxd_log(LL_ERROR, "%s: failed to read '%s': %s", __func__, device_record_file, strerror(errno)); + usbmuxd_log(LL_ERROR, "ERROR: Failed to read '%s': %s", device_record_file, strerror(errno)); res = -ENOENT; } free(device_record_file); @@ -490,7 +490,7 @@ int config_remove_device_record(const char *udid) /* remove file */ if (remove(device_record_file) != 0) { res = -errno; - usbmuxd_log(LL_DEBUG, "could not remove %s: %s", device_record_file, strerror(errno)); + usbmuxd_log(LL_DEBUG, "Could not remove %s: %s", device_record_file, strerror(errno)); } free(device_record_file); @@ -527,6 +527,6 @@ void config_device_record_get_host_id(const char *udid, char **host_id) plist_free(value); if (!*host_id) { - usbmuxd_log(LL_ERROR, "%s: ERROR couldn't get HostID from pairing record for udid %s", __func__, udid); + usbmuxd_log(LL_ERROR, "ERROR: Could not get HostID from pairing record for udid %s", udid); } } 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, char* buf = malloc(payload_length); strncpy(buf, (char*)payload+1, payload_length-1); buf[payload_length-1] = '\0'; - usbmuxd_log(LL_ERROR, "%s: ERROR: %s", __func__, buf); + usbmuxd_log(LL_ERROR, "%s: ERROR (on device): %s", __func__, buf); free(buf); } else { - usbmuxd_log(LL_ERROR, "%s: Error occurred, but empty error message", __func__); + usbmuxd_log(LL_ERROR, "%s: Got device error payload with empty message", __func__); } break; case 7: @@ -617,7 +617,7 @@ static void device_control_input(struct mux_device *dev, unsigned char *payload, break; } } else { - usbmuxd_log(LL_WARNING, "%s: got a type 1 packet without payload", __func__); + usbmuxd_log(LL_WARNING, "%s: Got a type 1 packet without payload", __func__); } } -- cgit v1.1-32-gdbae