summaryrefslogtreecommitdiffstats
path: root/src/utils.c
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/utils.c
parentd01cc63dc48349456b2d34cccab69d39eb1930cf (diff)
downloadlibimobiledevice-bc2f3964851dff088dd47a08997e6c6730258834.tar.gz
libimobiledevice-bc2f3964851dff088dd47a08997e6c6730258834.tar.bz2
Improve logging mechanism.
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c26
1 files changed, 26 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
25int toto_debug = 0; 25int toto_debug = 0;
26uint16_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 */
45void iphone_set_debug_mask(uint16_t mask)
46{
47 dbg_mask = mask;
48}
39 49
40void log_debug_msg(const char *format, ...) 50void 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
66void 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
56inline void log_debug_buffer(const char *data, const int length) 82inline void log_debug_buffer(const char *data, const int length)
57{ 83{
58#ifndef STRIP_DEBUG_CODE 84#ifndef STRIP_DEBUG_CODE