From 6205262d38a4f7c5f97f1cb4025914ee18abd74d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Feb 2013 08:23:42 +0100 Subject: [PATCH] lib/util: allow samba_tevent_debug() to take a name as context Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam --- lib/util/tevent_debug.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/util/tevent_debug.c b/lib/util/tevent_debug.c index 3a5a3132f99..6df58aeaf01 100644 --- a/lib/util/tevent_debug.c +++ b/lib/util/tevent_debug.c @@ -30,7 +30,7 @@ static void samba_tevent_debug(void *context, va_list ap) { int samba_level = -1; - char *s = NULL; + switch (level) { case TEVENT_DEBUG_FATAL: samba_level = 0; @@ -47,10 +47,21 @@ static void samba_tevent_debug(void *context, }; if (CHECK_DEBUGLVL(samba_level)) { - vasprintf(&s, fmt, ap); - if (!s) return; - DEBUG(samba_level, ("samba_tevent: %s", s)); - free(s); + const char *name = (const char *)context; + char *message = NULL; + int ret; + + ret = vasprintf(&message, fmt, ap); + if (ret == -1) { + return; + } + + if (name == NULL) { + name = "samba_tevent"; + } + + DEBUG(samba_level, ("%s: %s", name, message)); + free(message); } } -- 2.11.4.GIT