diff options
| author | 2010-01-22 13:45:53 +0100 | |
|---|---|---|
| committer | 2010-01-22 13:45:53 +0100 | |
| commit | ab56c34e17f2f44fd51ff3e890c002215fbe7690 (patch) | |
| tree | 75a8ba61bec72e351d466739ef5dfa751a1b46fd /src/debug.c | |
| parent | 808d461fea2c1b028e8fbb232eb09a94555856e8 (diff) | |
| download | libimobiledevice-ab56c34e17f2f44fd51ff3e890c002215fbe7690.tar.gz libimobiledevice-ab56c34e17f2f44fd51ff3e890c002215fbe7690.tar.bz2 | |
Turn debug_plist into macro to show caller func/file/line and improve output
Diffstat (limited to 'src/debug.c')
| -rw-r--r-- | src/debug.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/debug.c b/src/debug.c index 2cdeebf..b194b0d 100644 --- a/src/debug.c +++ b/src/debug.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * contains utilitary functions for debugging | 3 | * contains utilitary functions for debugging |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. | 5 | * Copyright (c) 2008 Jonathan Beck All Rights Reserved. |
| 6 | * Copyright (c) 2010 Martin S. All Rights Reserved. | ||
| 6 | * | 7 | * |
| 7 | * This library is free software; you can redistribute it and/or | 8 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public | 9 | * modify it under the terms of the GNU Lesser General Public |
| @@ -56,10 +57,12 @@ static void debug_print_line(const char *func, const char *file, int line, const | |||
| 56 | (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func); | 57 | (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func); |
| 57 | free (str_time); | 58 | free (str_time); |
| 58 | 59 | ||
| 59 | /* always in light green */ | 60 | /* trim ending newlines */ |
| 61 | |||
| 62 | /* print header */ | ||
| 60 | printf ("%s: ", header); | 63 | printf ("%s: ", header); |
| 61 | 64 | ||
| 62 | /* different colors according to the severity */ | 65 | /* print actual debug content */ |
| 63 | printf ("%s\n", buffer); | 66 | printf ("%s\n", buffer); |
| 64 | 67 | ||
| 65 | /* flush this output, as we need to debug */ | 68 | /* flush this output, as we need to debug */ |
| @@ -135,7 +138,7 @@ inline void debug_buffer_to_file(const char *file, const char *data, const int l | |||
| 135 | #endif | 138 | #endif |
| 136 | } | 139 | } |
| 137 | 140 | ||
| 138 | inline void debug_plist(plist_t plist) | 141 | inline void debug_plist_real(const char *func, const char *file, int line, plist_t plist) |
| 139 | { | 142 | { |
| 140 | #ifndef STRIP_DEBUG_CODE | 143 | #ifndef STRIP_DEBUG_CODE |
| 141 | if (!plist) | 144 | if (!plist) |
| @@ -144,7 +147,12 @@ inline void debug_plist(plist_t plist) | |||
| 144 | char *buffer = NULL; | 147 | char *buffer = NULL; |
| 145 | uint32_t length = 0; | 148 | uint32_t length = 0; |
| 146 | plist_to_xml(plist, &buffer, &length); | 149 | plist_to_xml(plist, &buffer, &length); |
| 147 | debug_info("plist size: %i\nbuffer :\n%s", length, buffer); | 150 | |
| 151 | /* get rid of ending newline as one is already added in the debug line */ | ||
| 152 | if (buffer[length-1] == '\n') | ||
| 153 | buffer[length-1] = '\0'; | ||
| 154 | |||
| 155 | debug_info_real(func, file, line, "printing %i bytes plist:\n%s", length, buffer); | ||
| 148 | free(buffer); | 156 | free(buffer); |
| 149 | #endif | 157 | #endif |
| 150 | } | 158 | } |
