Added level argument of mu_debug_print() to the print callback, useful
for determing the level and forwarding to syslog, or something.
Showing
3 changed files
with
10 additions
and
7 deletions
... | @@ -36,8 +36,10 @@ extern "C" { | ... | @@ -36,8 +36,10 @@ extern "C" { |
36 | struct _debug; | 36 | struct _debug; |
37 | typedef struct _debug* mu_debug_t; | 37 | typedef struct _debug* mu_debug_t; |
38 | 38 | ||
39 | #define MU_DEBUG_TRACE 1 | 39 | #define MU_DEBUG_ERROR 1 |
40 | #define MU_DEBUG_PROT 2 | 40 | #define MU_DEBUG_TRACE 2 |
41 | #define MU_DEBUG_PROT 3 | ||
42 | |||
41 | extern int mu_debug_create __P ((mu_debug_t *, void *owner)); | 43 | extern int mu_debug_create __P ((mu_debug_t *, void *owner)); |
42 | extern void mu_debug_destroy __P ((mu_debug_t *, void *owner)); | 44 | extern void mu_debug_destroy __P ((mu_debug_t *, void *owner)); |
43 | extern void * mu_debug_get_owner __P ((mu_debug_t)); | 45 | extern void * mu_debug_get_owner __P ((mu_debug_t)); |
... | @@ -47,7 +49,7 @@ extern int mu_debug_print __P ((mu_debug_t debug, size_t level, | ... | @@ -47,7 +49,7 @@ extern int mu_debug_print __P ((mu_debug_t debug, size_t level, |
47 | const char *format, ...)); | 49 | const char *format, ...)); |
48 | extern int mu_debug_printv __P ((mu_debug_t debug, size_t level, | 50 | extern int mu_debug_printv __P ((mu_debug_t debug, size_t level, |
49 | const char *format, va_list argp)); | 51 | const char *format, va_list argp)); |
50 | extern int mu_debug_set_print __P ((mu_debug_t, int (*_print) __P ((mu_debug_t, const char *, va_list)), void *owner)); | 52 | extern int mu_debug_set_print __P ((mu_debug_t, int (*_print) __P ((mu_debug_t, size_t level, const char *, va_list)), void *owner)); |
51 | 53 | ||
52 | #ifdef __cplusplus | 54 | #ifdef __cplusplus |
53 | } | 55 | } | ... | ... |
... | @@ -80,8 +80,9 @@ mu_debug_get_level (mu_debug_t debug, size_t *plevel) | ... | @@ -80,8 +80,9 @@ mu_debug_get_level (mu_debug_t debug, size_t *plevel) |
80 | } | 80 | } |
81 | 81 | ||
82 | int | 82 | int |
83 | mu_debug_set_print (mu_debug_t debug, int (*_print) | 83 | mu_debug_set_print (mu_debug_t debug, |
84 | __P ((mu_debug_t, const char *, va_list)), void *owner) | 84 | int (*_print) __P ((mu_debug_t, size_t, const char *, va_list)), |
85 | void *owner) | ||
85 | { | 86 | { |
86 | if (debug == NULL) | 87 | if (debug == NULL) |
87 | return EINVAL; | 88 | return EINVAL; |
... | @@ -115,7 +116,7 @@ mu_debug_printv (mu_debug_t debug, size_t level, const char *format, va_list ap) | ... | @@ -115,7 +116,7 @@ mu_debug_printv (mu_debug_t debug, size_t level, const char *format, va_list ap) |
115 | return 0; | 116 | return 0; |
116 | 117 | ||
117 | if (debug->_print) | 118 | if (debug->_print) |
118 | debug->_print (debug, format, ap); | 119 | debug->_print (debug, level, format, ap); |
119 | else | 120 | else |
120 | vfprintf (stderr, format, ap); | 121 | vfprintf (stderr, format, ap); |
121 | 122 | ... | ... |
... | @@ -42,7 +42,7 @@ struct _debug | ... | @@ -42,7 +42,7 @@ struct _debug |
42 | char *buffer; | 42 | char *buffer; |
43 | size_t buflen; | 43 | size_t buflen; |
44 | void *owner; | 44 | void *owner; |
45 | int (*_print) __P ((mu_debug_t, const char *, va_list)); | 45 | int (*_print) __P ((mu_debug_t, size_t level, const char *, va_list)); |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #ifdef __cplusplus | 48 | #ifdef __cplusplus | ... | ... |
-
Please register or sign in to post a comment