$Id$
+Sun Oct 30 23:03:49 EST 2005 ajc
+* When logging to syslog is enabled, SMTP transactions are now logged to
+ LOG_MAIL as well as whatever the normal facility is, in a format
+ similar to what conventional MTA's use. Resolves bugzilla issue #153.
+
Sun Oct 30 22:22:00 EST 2005 ajc
* syslog messages are now sent to the desired facility rather than always
going to LOG_DAEMON. There was a command line parsing bug.
#include <pwd.h>
#include <errno.h>
#include <sys/types.h>
+#include <syslog.h>
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
cprintf("%s", result);
}
+ /* Write something to the syslog (which may or may not be where the
+ * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
+ */
+ if (enable_syslog) {
+ syslog((LOG_MAIL | LOG_INFO),
+ "%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
+ msgnum,
+ SMTP->from,
+ SMTP->number_of_recipients,
+ CC->cs_host,
+ CC->cs_addr,
+ result
+ );
+ }
+
+ /* Clean up */
CtdlFreeMessage(msg);
free(valid);
smtp_data_clear(); /* clear out the buffers now */
bail: free(msgtext);
sock_close(sock);
+
+ /* Write something to the syslog (which may or may not be where the
+ * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
+ */
+ if (enable_syslog) {
+ syslog((LOG_MAIL | LOG_INFO),
+ "%ld: to=<%s>, relay=%s, stat=%s",
+ msgnum,
+ addr,
+ mx_host,
+ dsn
+ );
+ }
+
return;
}
drop_root_perms = 1;
}
- /* initialize the syslog facility */
+ /* Initialize the syslogger. Yes, we are really using 0 as the
+ * facility, because we are going to bitwise-OR the facility to
+ * the severity of each message, allowing us to write to other
+ * facilities when we need to...
+ */
if (enable_syslog) {
if (running_as_daemon) {
- openlog("citadel", LOG_NDELAY, syslog_facility);
+ openlog("citadel", LOG_NDELAY, 0);
}
else {
- openlog("citadel", LOG_PERROR|LOG_NDELAY,
- syslog_facility);
+ openlog("citadel", LOG_PERROR|LOG_NDELAY, 0);
}
setlogmask(LOG_UPTO(verbosity));
}
if (enable_syslog) {
va_start(arg_ptr, format);
- vsyslog(loglevel, format, arg_ptr);
+ vsyslog((syslog_facility | loglevel), format, arg_ptr);
va_end(arg_ptr);
}