diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-05-03 19:26:38 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2011-05-03 19:26:38 +0200 |
commit | a1527ce7177df11a8ee1b46a0e7b64f0f0df234b (patch) | |
tree | 41f724c2a04b3582878d40dc451930e71a7b86aa /debug.c | |
parent | c8a9a6550b84412f919b772a9cb8db1e3ef79d19 (diff) | |
parent | 808eaa49efe2dc2438ef98ddf4bac4cfd2898a3d (diff) | |
download | dovecot-antispam-master.tar.gz dovecot-antispam-master.tar.xz dovecot-antispam-master.zip |
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 46 |
1 files changed, 38 insertions, 8 deletions
@@ -4,22 +4,32 @@ #include <stdio.h> #include "antispam-plugin.h" +enum antispam_debug_target debug_target; +int verbose_debug; + static void _debug(const char *format, va_list ap) { const char *fmt; + if (debug_target == ADT_NONE) + return; + t_push(); fmt = t_strconcat(stringify(PLUGINNAME), ": ", format, NULL); -#if defined(DEBUG_SYSLOG) - vsyslog(LOG_DEBUG, fmt, ap); -#elif defined(DEBUG_STDERR) - vfprintf(stderr, fmt, ap); - fflush(stderr); -#else -#error no logging method -#endif + switch (debug_target) { + case ADT_NONE: + break; + case ADT_SYSLOG: + vsyslog(LOG_DEBUG, fmt, ap); + break; + case ADT_STDERR: + vfprintf(stderr, fmt, ap); + fflush(stderr); + break; + } + t_pop(); } @@ -64,3 +74,23 @@ void debugv(char **args) debug("%s", buf); t_pop(); } + +void debugv_not_stderr(char **args) +{ + if (debug_target == ADT_STDERR) + return; + + debugv(args); +} + +void debug_verbose(const char *fmt, ...) +{ + va_list args; + + if (!verbose_debug) + return; + + va_start(args, fmt); + _debug(fmt, args); + va_end(args); +} |