summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-01-09 19:23:43 +0100
committerGravatar Jonathan Beck2009-01-09 19:23:43 +0100
commitbc2f3964851dff088dd47a08997e6c6730258834 (patch)
tree940e2d0bfa373d792b34ef3aae74f47e7767134d /src
parentd01cc63dc48349456b2d34cccab69d39eb1930cf (diff)
downloadlibimobiledevice-bc2f3964851dff088dd47a08997e6c6730258834.tar.gz
libimobiledevice-bc2f3964851dff088dd47a08997e6c6730258834.tar.bz2
Improve logging mechanism.
Diffstat (limited to 'src')
-rw-r--r--src/utils.c26
-rw-r--r--src/utils.h8
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 @@
#include "utils.h"
int toto_debug = 0;
+uint16_t dbg_mask = 0;
/**
* Sets the level of debugging. Currently the only acceptable values are 0 and
@@ -36,6 +37,15 @@ void iphone_set_debug(int level)
}
+/**
+ * Set debug ids to display. Values can be OR-ed
+ *
+ * @param level Set to 0 for no debugging or 1 for debugging.
+ */
+void iphone_set_debug_mask(uint16_t mask)
+{
+ dbg_mask = mask;
+}
void log_debug_msg(const char *format, ...)
{
@@ -53,6 +63,22 @@ void log_debug_msg(const char *format, ...)
#endif
}
+void log_dbg_msg(uint16_t id, const char *format, ...)
+{
+#ifndef STRIP_DEBUG_CODE
+
+ if (id & dbg_mask) {
+ va_list args;
+ /* run the real fprintf */
+ va_start(args, format);
+
+ vfprintf(stderr, format, args);
+
+ va_end(args);
+ }
+#endif
+}
+
inline void log_debug_buffer(const char *data, const int length)
{
#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 @@
#include "libiphone/libiphone.h"
+#define DBGMASK_USBMUX (1 << 1)
+#define DBGMASK_LOCKDOWND (1 << 2)
+#define DBGMASK_MOBILESYNC (1 << 3)
+
+void iphone_set_debug_mask(uint16_t mask);
+
inline void log_debug_msg(const char *format, ...);
+inline void log_dbg_msg(uint16_t id, const char *format, ...);
+
inline void log_debug_buffer(const char *data, const int length);
inline void dump_debug_buffer(const char *file, const char *data, const int length);
#endif