diff options
| author | 2009-01-09 19:23:43 +0100 | |
|---|---|---|
| committer | 2009-01-09 19:23:43 +0100 | |
| commit | bc2f3964851dff088dd47a08997e6c6730258834 (patch) | |
| tree | 940e2d0bfa373d792b34ef3aae74f47e7767134d /src | |
| parent | d01cc63dc48349456b2d34cccab69d39eb1930cf (diff) | |
| download | libimobiledevice-bc2f3964851dff088dd47a08997e6c6730258834.tar.gz libimobiledevice-bc2f3964851dff088dd47a08997e6c6730258834.tar.bz2 | |
Improve logging mechanism.
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils.c | 26 | ||||
| -rw-r--r-- | src/utils.h | 8 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index fb98471..988cb03 100644 --- a/src/utils.c +++ b/src/utils.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include "utils.h" | 23 | #include "utils.h" |
| 24 | 24 | ||
| 25 | int toto_debug = 0; | 25 | int toto_debug = 0; |
| 26 | uint16_t dbg_mask = 0; | ||
| 26 | 27 | ||
| 27 | /** | 28 | /** |
| 28 | * Sets the level of debugging. Currently the only acceptable values are 0 and | 29 | * Sets the level of debugging. Currently the only acceptable values are 0 and |
| @@ -36,6 +37,15 @@ void iphone_set_debug(int level) | |||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | 39 | ||
| 40 | /** | ||
| 41 | * Set debug ids to display. Values can be OR-ed | ||
| 42 | * | ||
| 43 | * @param level Set to 0 for no debugging or 1 for debugging. | ||
| 44 | */ | ||
| 45 | void iphone_set_debug_mask(uint16_t mask) | ||
| 46 | { | ||
| 47 | dbg_mask = mask; | ||
| 48 | } | ||
| 39 | 49 | ||
| 40 | void log_debug_msg(const char *format, ...) | 50 | void log_debug_msg(const char *format, ...) |
| 41 | { | 51 | { |
| @@ -53,6 +63,22 @@ void log_debug_msg(const char *format, ...) | |||
| 53 | #endif | 63 | #endif |
| 54 | } | 64 | } |
| 55 | 65 | ||
| 66 | void log_dbg_msg(uint16_t id, const char *format, ...) | ||
| 67 | { | ||
| 68 | #ifndef STRIP_DEBUG_CODE | ||
| 69 | |||
| 70 | if (id & dbg_mask) { | ||
| 71 | va_list args; | ||
| 72 | /* run the real fprintf */ | ||
| 73 | va_start(args, format); | ||
| 74 | |||
| 75 | vfprintf(stderr, format, args); | ||
| 76 | |||
| 77 | va_end(args); | ||
| 78 | } | ||
| 79 | #endif | ||
| 80 | } | ||
| 81 | |||
| 56 | inline void log_debug_buffer(const char *data, const int length) | 82 | inline void log_debug_buffer(const char *data, const int length) |
| 57 | { | 83 | { |
| 58 | #ifndef STRIP_DEBUG_CODE | 84 | #ifndef STRIP_DEBUG_CODE |
diff --git a/src/utils.h b/src/utils.h index 489f610..c1a8e54 100644 --- a/src/utils.h +++ b/src/utils.h | |||
| @@ -24,7 +24,15 @@ | |||
| 24 | 24 | ||
| 25 | #include "libiphone/libiphone.h" | 25 | #include "libiphone/libiphone.h" |
| 26 | 26 | ||
| 27 | #define DBGMASK_USBMUX (1 << 1) | ||
| 28 | #define DBGMASK_LOCKDOWND (1 << 2) | ||
| 29 | #define DBGMASK_MOBILESYNC (1 << 3) | ||
| 30 | |||
| 31 | void iphone_set_debug_mask(uint16_t mask); | ||
| 32 | |||
| 27 | inline void log_debug_msg(const char *format, ...); | 33 | inline void log_debug_msg(const char *format, ...); |
| 34 | inline void log_dbg_msg(uint16_t id, const char *format, ...); | ||
| 35 | |||
| 28 | inline void log_debug_buffer(const char *data, const int length); | 36 | inline void log_debug_buffer(const char *data, const int length); |
| 29 | inline void dump_debug_buffer(const char *file, const char *data, const int length); | 37 | inline void dump_debug_buffer(const char *file, const char *data, const int length); |
| 30 | #endif | 38 | #endif |
