aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2009-04-17 21:58:53 +0000
committerAndreas Steffen <andreas.steffen@strongswan.org>2009-04-17 21:58:53 +0000
commit815510e6372300604a8e6b3c5642c747248b8b66 (patch)
tree064249fb745d6feb962b802e7187c4a1fc5fc6c4 /src
parentc889ce80abff3b2f2f2da9ba41d4e7e5ee800521 (diff)
downloadstrongswan-815510e6372300604a8e6b3c5642c747248b8b66.tar.bz2
strongswan-815510e6372300604a8e6b3c5642c747248b8b66.tar.xz
improved openac dbg function handling multiple lines to syslog
Diffstat (limited to 'src')
-rwxr-xr-xsrc/openac/openac.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/openac/openac.c b/src/openac/openac.c
index 3d25160d5..a35bc51ad 100755
--- a/src/openac/openac.c
+++ b/src/openac/openac.c
@@ -218,18 +218,35 @@ static bool stderr_quiet = FALSE;
static void openac_dbg(int level, char *fmt, ...)
{
int priority = LOG_INFO;
+ char buffer[8192];
+ char *current = buffer, *next;
va_list args;
if (level <= debug_level)
{
va_start(args, fmt);
+
if (!stderr_quiet)
{
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
- vsyslog(priority, fmt, args);
+
+ /* write in memory buffer first */
+ vsnprintf(buffer, sizeof(buffer), fmt, args);
va_end(args);
+
+ /* do a syslog with every line */
+ while (current)
+ {
+ next = strchr(current, '\n');
+ if (next)
+ {
+ *(next++) = '\0';
+ }
+ syslog(priority, "%s\n", current);
+ current = next;
+ }
}
}