aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2011-05-03 19:26:38 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2011-05-03 19:26:38 +0200
commita1527ce7177df11a8ee1b46a0e7b64f0f0df234b (patch)
tree41f724c2a04b3582878d40dc451930e71a7b86aa /debug.c
parentc8a9a6550b84412f919b772a9cb8db1e3ef79d19 (diff)
parent808eaa49efe2dc2438ef98ddf4bac4cfd2898a3d (diff)
downloaddovecot-antispam-master.tar.gz
dovecot-antispam-master.tar.xz
dovecot-antispam-master.zip
merge with base/masterHEADmaster
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/debug.c b/debug.c
index 7f3e407..a3e0fc4 100644
--- a/debug.c
+++ b/debug.c
@@ -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);
+}