summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-06-10 00:10:04 +0000
committerStef Walter <stef@memberwebs.com>2008-06-10 00:10:04 +0000
commit33846e5122fbf8a964f278eb01ad821e643bb63c (patch)
treecfdb39d88ac62ffc9e5d5edb07fe9550d703a2cd
parent102b6d7ff290a3df504915363bdf2268553e5f87 (diff)
Add syslog logging
-rw-r--r--configure.in9
-rw-r--r--plugin/plugin.c13
2 files changed, 18 insertions, 4 deletions
diff --git a/configure.in b/configure.in
index d17e554..f366211 100644
--- a/configure.in
+++ b/configure.in
@@ -87,6 +87,15 @@ if test "$enable_debug" = "yes"; then
echo "enabling debug compile mode"
fi
+# Log to syslog
+AC_ARG_WITH(syslog,
+ AC_HELP_STRING([--without-syslog],
+ [Don't log to syslog in addition to slapd logs]))
+
+if test "$with_syslog" != "no"; then
+ AC_DEFINE_UNQUOTED(WITH_SYSLOG, 1, [With syslog logging])
+fi
+
AC_CONFIG_FILES([
Makefile
plugin/Makefile
diff --git a/plugin/plugin.c b/plugin/plugin.c
index c34294a..54144ba 100644
--- a/plugin/plugin.c
+++ b/plugin/plugin.c
@@ -11,6 +11,9 @@
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
+#ifdef WITH_SYSLOG
+#include <syslog.h>
+#endif
#define WHITESPACE " \t\r\n\v"
@@ -35,8 +38,10 @@ log_msg_va (int level, const char* msg, va_list ap)
buf[len] = '\n';
buf[len + 1] = '\0';
-#if _DEBUG
- fprintf (stderr, "%s", buf);
+ fprintf (stderr, "%s: %s", PLUGIN_NAME, buf);
+#ifdef WITH_SYSLOG
+ if (level != SLAPI_LOG_TRACE)
+ syslog (LOG_WARNING | LOG_DAEMON, "%s: %s", PLUGIN_NAME, buf);
#endif
slapi_log_error (level, PLUGIN_NAME, buf);
}
@@ -54,8 +59,8 @@ log_msg (int level, const char* msg, ...)
void
log_trace (const char *where, int line, const char *msg)
{
- log_msg (SLAPI_LOG_TRACE, "*** %s *** %s:%d %s%s",
- PLUGIN_NAME, where, line, msg ? ": " : "", msg ? msg : "");
+ log_msg (SLAPI_LOG_TRACE, " *** %s:%d %s%s",
+ where, line, msg ? ": " : "", msg ? msg : "");
}
#endif