diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-01-08 15:16:51 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-01-09 08:45:40 +0100 |
commit | def5e8e889e0ffe1cf55462ca32b69b627c5ff96 (patch) | |
tree | a0edae055f885cd9078fa8a3cfde09b33b8a1ace /source3/lib | |
parent | 447f2668879e91990c985bdb8f0c5d5db2719a91 (diff) | |
download | samba-def5e8e889e0ffe1cf55462ca32b69b627c5ff96.tar.gz samba-def5e8e889e0ffe1cf55462ca32b69b627c5ff96.tar.bz2 samba-def5e8e889e0ffe1cf55462ca32b69b627c5ff96.zip |
s3:events: install a tevent debug handler that calls DEBUG()
metze
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/events.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/source3/lib/events.c b/source3/lib/events.c index c1feff8c67..92c1f7fd1d 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -274,8 +274,49 @@ static bool s3_tevent_init(void) return initialized; } +/* + this is used to catch debug messages from events +*/ +static void s3_event_debug(void *context, enum tevent_debug_level level, + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); + +static void s3_event_debug(void *context, enum tevent_debug_level level, + const char *fmt, va_list ap) +{ + int samba_level = -1; + char *s = NULL; + switch (level) { + case TEVENT_DEBUG_FATAL: + samba_level = 0; + break; + case TEVENT_DEBUG_ERROR: + samba_level = 1; + break; + case TEVENT_DEBUG_WARNING: + samba_level = 2; + break; + case TEVENT_DEBUG_TRACE: + samba_level = 5; + break; + + }; + vasprintf(&s, fmt, ap); + if (!s) return; + DEBUG(samba_level, ("s3_event: %s", s)); + free(s); +} + struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx) { + struct tevent_context *ev; + s3_tevent_init(); - return tevent_context_init_byname(mem_ctx, "s3"); + + ev = tevent_context_init_byname(mem_ctx, "s3"); + if (ev) { + tevent_set_debug(ev, s3_event_debug, NULL); + } + + return ev; } + |