diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-02-21 08:23:42 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-02-28 12:10:05 +0100 |
commit | 6205262d38a4f7c5f97f1cb4025914ee18abd74d (patch) | |
tree | c4d489a88031e69b847fe43af5a52d6d1aa6411d /lib/util | |
parent | bf0dcc918dc63939fb3d0b9ce9339b432b98cb74 (diff) | |
download | samba-6205262d38a4f7c5f97f1cb4025914ee18abd74d.tar.gz samba-6205262d38a4f7c5f97f1cb4025914ee18abd74d.tar.bz2 samba-6205262d38a4f7c5f97f1cb4025914ee18abd74d.zip |
lib/util: allow samba_tevent_debug() to take a name as context
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/tevent_debug.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/util/tevent_debug.c b/lib/util/tevent_debug.c index 3a5a3132f9..6df58aeaf0 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); } } |