aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
blob: 6af58230503e3955ec633c99a46849b2e6d4a34e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#define _BSD_SOURCE
#include <syslog.h>
#include <stdarg.h>
#include <stdio.h>
#include "antispam-plugin.h"

static void _debug(const char *format, va_list ap)
{
	const char *fmt;

	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
	t_pop();
}

void debug(const char *fmt, ...)
{
	va_list args;

	va_start(args, fmt);
	_debug(fmt, args);
	va_end(args);
}