summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2007-04-20 09:09:46 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2007-04-20 09:09:46 (GMT)
commitf0992a40ee322ea27371ed6b81dce893cb8cd4d8 (patch) (side-by-side diff)
tree8f216ae0aab3d309178816df14f4a8d31c2caf8f /src/main.c
parent5d78549a3171c8d058f1485e5cbc6f3d74770c9a (diff)
downloadmailfromd-f0992a40ee322ea27371ed6b81dce893cb8cd4d8.tar.gz
mailfromd-f0992a40ee322ea27371ed6b81dce893cb8cd4d8.tar.bz2
Implement asyncronous syslog
git-svn-id: file:///svnroot/mailfromd/trunk@1368 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index cec508b..d9871ce 100644
--- a/src/main.c
+++ b/src/main.c
@@ -111,7 +111,9 @@ time_t response_timeout = 30;
int
syslog_printer (int prio, const char *fmt, va_list ap)
{
-#ifdef HAVE_VSYSLOG
+#ifdef USE_SYSLOG_ASYNC
+ vsyslog_async (prio, fmt, ap);
+#elif HAVE_VSYSLOG
vsyslog (prio, fmt, ap);
#else
char buf[128];
@@ -121,6 +123,32 @@ syslog_printer (int prio, const char *fmt, va_list ap)
return 0;
}
+#ifdef USE_SYSLOG_ASYNC
+void
+mf_gacopyz_syslog_async_log_printer(int level, char *fmt, va_list ap)
+{
+ switch (level) {
+ case SMI_LOG_DEBUG:
+ level = LOG_DEBUG;
+ break;
+ case SMI_LOG_INFO:
+ level = LOG_INFO;
+ break;
+ case SMI_LOG_WARN:
+ level = LOG_WARNING;
+ break;
+ case SMI_LOG_ERR:
+ level = LOG_ERR;
+ break;
+
+ case SMI_LOG_FATAL:
+ default:
+ level = LOG_EMERG;
+ }
+ vsyslog_async(level, fmt, ap);
+}
+#endif
+
int
syslog_error_printer (const char *fmt, va_list ap)
{
@@ -1744,6 +1772,11 @@ mailfromd_show_defaults()
printf("statedir: %s\n", DEFAULT_STATE_DIR);
printf("socket: %s\n", DEFAULT_SOCKET);
printf("pidfile: %s\n", DEFAULT_PIDFILE);
+#ifdef USE_SYSLOG_ASYNC
+ printf("syslog: non-blocking\n");
+#else
+ printf("syslog: blocking\n");
+#endif
printf("database format: ");
#if defined WITH_GDBM
printf("GDBM");
@@ -1822,7 +1855,12 @@ main(int argc, char **argv)
/* Set up default values */
if (!log_to_stderr) {
+#ifdef USE_SYSLOG_ASYNC
+ openlog_async(syslog_tag, LOG_PID, log_facility);
+ gacopyz_set_logger (mf_gacopyz_syslog_async_log_printer);
+#else
openlog(syslog_tag, LOG_PID, log_facility);
+#endif
mu_error_set_print(syslog_error_printer);
} else
gacopyz_set_logger (gacopyz_stderr_log_printer);

Return to:

Send suggestions and report system problems to the System administrator.