SMTP-Client: add per facility debug logging 'smtpeventclient'
[citadel.git] / citadel / modules / smtp / serv_smtpeventclient.c
index 1698ab74773c1886d7152a3e6b088f1594b12abc..2869b8d44cc7e06c2531e71026f88bed4674549b 100644 (file)
@@ -90,6 +90,7 @@
 #include "smtpqueue.h"
 #include "smtp_clienthandlers.h"
 
+int SMTPClientDebugEnabled = 0;
 const unsigned short DefaultMXPort = 25;
 void DeleteSmtpOutMsg(void *v)
 {
@@ -147,8 +148,9 @@ inline void FinalizeMessageSend_1(AsyncIO *IO)
                Status = "Delivery failed temporarily; will retry later.";
                        
        EVS_syslog(LOG_INFO,
-                  "SMTP: %s Recipient <%s> @ <%s> (%s) Statusmessage: %s\n",
+                  "SMTP: %s Time[%fs] Recipient <%s> @ <%s> (%s) Statusmessage: %s\n",
                   Status,
+                  Msg->IO.Now - Msg->IO.StartIO,
                   Msg->user,
                   Msg->node,
                   Msg->name,
@@ -372,6 +374,9 @@ eNextState get_one_mx_host_ip_done(AsyncIO *IO)
        struct hostent *hostent;
 
        QueryCbDone(IO);
+       EVS_syslog(LOG_DEBUG, "SMTP: %s Time[%fs]\n",
+                  __FUNCTION__,
+                  IO->Now - IO->DNS.Start);
 
        hostent = Msg->HostLookup.VParsedDNSReply;
        if ((Msg->HostLookup.DNSStatus == ARES_SUCCESS) &&
@@ -467,7 +472,9 @@ eNextState smtp_resolve_mx_record_done(AsyncIO *IO)
 
        QueryCbDone(IO);
 
-       EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       EVS_syslog(LOG_DEBUG, "SMTP: %s Time[%fs]\n",
+                  __FUNCTION__,
+               IO->Now - IO->DNS.Start);
 
        pp = &Msg->Relay;
        while ((pp != NULL) && (*pp != NULL) && ((*pp)->Next != NULL))
@@ -823,7 +830,14 @@ eReadState SMTP_C_ReadServerStatus(AsyncIO *IO)
        return Finished;
 }
 
+void LogDebugEnableSMTPClient(void)
+{
+       SMTPClientDebugEnabled = 1;
+}
+
 CTDL_MODULE_INIT(smtp_eventclient)
 {
+       if (!threading)
+               CtdlRegisterDebugFlagHook(HKEY("smtpeventclient"), LogDebugEnableSMTPClient);
        return "smtpeventclient";
 }