Bug 1075149 - distinguish different server connections in the POP3 log. r=rkent a=jorgk
authoraceman <acelists@atlas.sk>
Tue, 09 Feb 2016 00:49:40 +0100
changeset 26798 c49a8312cd4cb69deddb1aa1c31aaab288fb40ee
parent 26797 ef52b0bf9e662ffcb329adb5d81d9af59a14c630
child 26799 95d5d062c4e36034f5bac0b0e428edbab5da366f
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, jorgk
bugs1075149
Bug 1075149 - distinguish different server connections in the POP3 log. r=rkent a=jorgk
mailnews/local/src/nsPop3Protocol.cpp
mailnews/local/src/nsPop3Sink.cpp
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -44,17 +44,17 @@
 #include "nsIProxyInfo.h"
 #include "nsCRT.h"
 #include "mozilla/Services.h"
 #include "mozilla/Logging.h"
 
 using namespace mozilla;
 
 PRLogModuleInfo *POP3LOGMODULE = nullptr;
-
+#define POP3LOG(str) "%s: [this=%p] " str, POP3LOGMODULE->name, this
 
 static int
 net_pop3_remove_messages_marked_delete(PLHashEntry* he,
                                        int msgindex,
                                        void *arg)
 {
   Pop3UidlEntry *uidlEntry = (Pop3UidlEntry *) he->value;
   return (uidlEntry->status == DELETE_CHAR)
@@ -456,16 +456,18 @@ nsPop3Protocol::nsPop3Protocol(nsIURI* a
 }
 
 nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
 {
   nsresult rv = NS_OK;
   if (!POP3LOGMODULE)
     POP3LOGMODULE = PR_NewLogModule("POP3");
 
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("Initialize()")));
+
   m_pop3ConData = (Pop3ConData *)PR_NEWZAP(Pop3ConData);
   if(!m_pop3ConData)
     return NS_ERROR_OUT_OF_MEMORY;
 
   m_totalBytesReceived = 0;
   m_bytesInMsgReceived = 0;
   m_totalFolderSize = 0;
   m_totalDownloadSize = 0;
@@ -566,17 +568,17 @@ nsresult nsPop3Protocol::Initialize(nsIU
     mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   return bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(mLocalBundle));
 }
 
 nsPop3Protocol::~nsPop3Protocol()
 {
   Cleanup();
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("~nsPop3Protocol()"));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("~nsPop3Protocol()")));
 }
 
 void nsPop3Protocol::Cleanup()
 {
   if (m_pop3ConData->newuidl)
   {
     PL_HashTableDestroy(m_pop3ConData->newuidl);
     m_pop3ConData->newuidl = nullptr;
@@ -738,17 +740,17 @@ nsresult nsPop3Protocol::StartGetAsyncPa
   // Explict NS_ENSURE_SUCCESS for debug purposes as errors tend to get
   // hidden.
   NS_ENSURE_SUCCESS(rv, rv);
   return rv;
 }
 
 NS_IMETHODIMP nsPop3Protocol::OnPromptStart(bool *aResult)
 {
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("OnPromptStart()"));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("OnPromptStart()")));
 
   *aResult = false;
 
   nsresult rv;
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString passwordResult;
@@ -780,25 +782,25 @@ NS_IMETHODIMP nsPop3Protocol::OnPromptSt
   // if the last prompt got us a bad password then show a special dialog
   if (TestFlag(POP3_PASSWORD_FAILED))
   {
     // Biff case (no msgWindow) shouldn't cause prompts or passwords to get forgotten at all
     // TODO shouldn't we skip the new password prompt below as well for biff? Just exit here?
     if (msgWindow)
     {
       MOZ_LOG(POP3LOGMODULE, LogLevel::Warning,
-          ("POP: ask user what to do (after password failed): new password, retry or cancel"));
+              (POP3LOG("POP: ask user what to do (after password failed): new password, retry or cancel")));
 
       int32_t buttonPressed = 0;
       if (NS_SUCCEEDED(MsgPromptLoginFailed(msgWindow, hostName,
                                             &buttonPressed)))
       {
         if (buttonPressed == 1) // Cancel button
         {
-          MOZ_LOG(POP3LOGMODULE, LogLevel::Warning, ("cancel button pressed"));
+          MOZ_LOG(POP3LOGMODULE, LogLevel::Warning, (POP3LOG("cancel button pressed")));
           // Abort quickly and stop trying for now.
 
           // If we haven't actually connected yet (i.e. we're doing an early
           // attempt to get the username/password but we've previously failed
           // for some reason), then skip straight to POP3_FREE as it isn't an
           // error in this connection, and just ends up with us closing the
           // socket and saying we've aborted the bind. Otherwise, pretend this
           // is an error and move on.
@@ -816,32 +818,32 @@ NS_IMETHODIMP nsPop3Protocol::OnPromptSt
 
           // As we're async, calling ProcessProtocolState gets things going
           // again.
           ProcessProtocolState(nullptr, nullptr, 0, 0);
           return NS_OK;
         }
         else if (buttonPressed == 2) // "New password" button
         {
-          MOZ_LOG(POP3LOGMODULE, LogLevel::Warning, ("new password button pressed"));
+          MOZ_LOG(POP3LOGMODULE, LogLevel::Warning, (POP3LOG("new password button pressed")));
           // Forget the stored password
           // and we'll prompt for a new one next time around.
           rv = server->ForgetPassword();
           NS_ENSURE_SUCCESS(rv, rv);
 
           // try all methods again with new password
           ResetAuthMethods();
           // ... apart from GSSAPI, which doesn't care about passwords
           MarkAuthMethodAsFailed(POP3_HAS_AUTH_GSSAPI);
           if (m_needToRerunUrl)
             return RerunUrl();
         }
         else if (buttonPressed == 0) // "Retry" button
         {
-          MOZ_LOG(POP3LOGMODULE, LogLevel::Warning, ("retry button pressed"));
+          MOZ_LOG(POP3LOGMODULE, LogLevel::Warning, (POP3LOG("retry button pressed")));
           // try all methods again, including GSSAPI
           ResetAuthMethods();
           ClearFlag(POP3_PASSWORD_FAILED|POP3_AUTH_FAILURE);
 
           if (m_needToRerunUrl)
             return RerunUrl();
 
           // It is a bit strange that we're going onto the next state that 
@@ -932,17 +934,17 @@ NS_IMETHODIMP nsPop3Protocol::OnStopRequ
   {
     // Check if the connection was dropped before getting back an auth error.
     // If we got the auth error, the next state would be
     // POP3_OBTAIN_PASSWORD_EARLY.
     if ((m_pop3ConData->next_state_after_response == POP3_NEXT_AUTH_STEP ||
          m_pop3ConData->next_state_after_response == POP3_AUTH_LOGIN_RESPONSE) &&
         m_pop3ConData->next_state != POP3_OBTAIN_PASSWORD_EARLY)
     {
-      MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("dropped connection before auth error"));
+      MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("dropped connection before auth error")));
       SetFlag(POP3_AUTH_FAILURE);
       m_pop3ConData->command_succeeded = false;
       m_needToRerunUrl = true;
       m_pop3ConData->next_state = POP3_NEXT_AUTH_STEP;
       ProcessProtocolState(nullptr, nullptr, 0, 0);
     }
     // We can't call nsMsgProtocol::OnStopRequest because it calls SetUrlState,
     // which notifies the URLListeners, but we need to do a bit of cleanup
@@ -955,48 +957,54 @@ NS_IMETHODIMP nsPop3Protocol::OnStopRequ
     return NS_OK;
   }
   nsresult rv = nsMsgProtocol::OnStopRequest(aRequest, aContext, aStatus);
 
   // turn off the server busy flag on stop request - we know we're done, right?
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
   if (server)
   {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("Clearing server busy in OnStopRequest"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
+            (POP3LOG("Clearing server busy in nsPop3Protocol::OnStopRequest")));
     server->SetServerBusy(false); // the server is not busy
   }
   if(m_pop3ConData->list_done)
     CommitState(true);
   if (NS_FAILED(aStatus) && aStatus != NS_BINDING_ABORTED)
     Abort();
   return rv;
 }
 
 void nsPop3Protocol::Abort()
 {
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("Abort")));
+
   if(m_pop3ConData->msg_closure)
   {
       m_nsIPop3Sink->IncorporateAbort(m_pop3ConData->only_uidl != nullptr);
       m_pop3ConData->msg_closure = nullptr;
   }
   // need this to close the stream on the inbox.
   m_nsIPop3Sink->AbortMailDelivery(this);
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("Clearing running protocol in nsPop3Protocol::Abort"));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
+          (POP3LOG("Clearing running protocol in nsPop3Protocol::Abort()")));
   m_pop3Server->SetRunningProtocol(nullptr);
 }
 
 NS_IMETHODIMP nsPop3Protocol::Cancel(nsresult status)  // handle stop button
 {
   Abort();
   return nsMsgProtocol::Cancel(NS_BINDING_ABORTED);
 }
 
 
 nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
 {
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("LoadUrl()")));
+
   nsresult rv = Initialize(aURL);
   NS_ENSURE_SUCCESS(rv, rv);
   if (aURL)
     m_url = do_QueryInterface(aURL);
   else
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIURL> url = do_QueryInterface(aURL, &rv);
@@ -1057,20 +1065,24 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI*
   nsCString hostName;
   nsCString userName;
 
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
   if (server)
   {
     rv = server->GetLocalPath(getter_AddRefs(mailDirectory));
     NS_ENSURE_SUCCESS(rv, rv);
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("Setting server busy in nsPop3Protocol::LoadUrl"));
     server->SetServerBusy(true); // the server is now busy
     server->GetHostName(hostName);
     server->GetUsername(userName);
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Info,
+            (POP3LOG("Connecting to server %s:%d"), hostName.get(), port));
+
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
+            (POP3LOG("Setting server busy in nsPop3Protocol::LoadUrl()")));
   }
 
   if (!m_pop3ConData->verify_logon)
     m_pop3ConData->uidlinfo = net_pop3_load_state(hostName.get(), userName.get(), mailDirectory);
 
   m_pop3ConData->biffstate = nsIMsgFolder::nsMsgBiffState_NoMail;
 
   if (m_pop3ConData->uidlinfo && numDaysToLeaveOnServer > 0)
@@ -1126,17 +1138,17 @@ nsPop3Protocol::WaitForStartOfConnection
                                                  uint32_t length)
 {
   char * line = nullptr;
   uint32_t line_length = 0;
   bool pauseForMoreData = false;
   nsresult rv;
   line = m_lineStreamBuffer->ReadNextLine(aInputStream, line_length, pauseForMoreData, &rv);
 
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
   if (NS_FAILED(rv))
     return -1;
 
   if(pauseForMoreData || !line)
   {
     m_pop3ConData->pause_for_read = true; /* pause */
     PR_Free(line);
     return(line_length);
@@ -1182,17 +1194,17 @@ nsPop3Protocol::WaitForResponse(nsIInput
   if(pauseForMoreData || !line)
   {
     m_pop3ConData->pause_for_read = true; /* pause */
 
     PR_Free(line);
     return(ln);
   }
 
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
 
   if(*line == '+')
   {
     m_pop3ConData->command_succeeded = true;
     if(PL_strlen(line) > 4)
     {
       if(!PL_strncasecmp(line, "+OK", 3))
         m_commandResponse = line + 4;
@@ -1211,17 +1223,17 @@ nsPop3Protocol::WaitForResponse(nsIInput
       m_commandResponse  = line;
 
     // search for the response codes (RFC 2449, chapter 8 and RFC 3206)
     if(TestCapFlag(POP3_HAS_RESP_CODES | POP3_HAS_AUTH_RESP_CODE))
     {
         // code for authentication failure due to the user's credentials
         if(m_commandResponse.Find("[AUTH", true) >= 0)
         {
-          MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("setting auth failure"));
+          MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("setting auth failure")));
           SetFlag(POP3_AUTH_FAILURE);
         }
 
         // codes for failures due to other reasons
         if(m_commandResponse.Find("[LOGIN-DELAY", true) >= 0 ||
            m_commandResponse.Find("[IN-USE", true) >= 0 ||
            m_commandResponse.Find("[SYS", true) >= 0)
       SetFlag(POP3_STOPLOGIN);
@@ -1240,18 +1252,17 @@ nsPop3Protocol::WaitForResponse(nsIInput
   return(1);  /* everything ok */
 }
 
 int32_t
 nsPop3Protocol::Error(const char* err_code,
                       const char16_t **params,
                       uint32_t length)
 {
-    
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, ("ERROR: %s", err_code));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("ERROR: %s"), err_code));
 
     // the error code is just the resource name for the error string...
     // so print out that error message!
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
     nsString accountName;
     nsresult rv = server->GetPrettyName(accountName);
     NS_ENSURE_SUCCESS(rv, -1);
     const char16_t *titleParams[] = { accountName.get() };
@@ -1319,38 +1330,41 @@ int32_t nsPop3Protocol::Pop3SendData(con
   // remove any leftover bytes in the line buffer
   // this can happen if the last message line doesn't end with a (CR)LF
   // or a server sent two reply lines
   m_lineStreamBuffer->ClearBuffer();
 
   nsresult result = nsMsgProtocol::SendData(dataBuffer);
 
   if (!aSuppressLogging)
-      MOZ_LOG(POP3LOGMODULE, LogLevel::Info, ("SEND: %s", dataBuffer));
+      MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("SEND: %s"), dataBuffer));
   else
-      MOZ_LOG(POP3LOGMODULE, LogLevel::Info, ("Logging suppressed for this command (it probably contained authentication information)"));
+      MOZ_LOG(POP3LOGMODULE, LogLevel::Info,
+              (POP3LOG("Logging suppressed for this command (it probably contained authentication information)")));
 
   if (NS_SUCCEEDED(result))
   {
     m_pop3ConData->pause_for_read = true;
     m_pop3ConData->next_state = POP3_WAIT_FOR_RESPONSE;
     return 0;
   }
 
   m_pop3ConData->next_state = POP3_ERROR_DONE;
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, ("Pop3SendData failed: %lx", result));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("Pop3SendData failed: %lx"), result));
   return -1;
 }
 
 /*
  * POP3 AUTH extension
  */
 
 int32_t nsPop3Protocol::SendAuth()
 {
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("SendAuth()")));
+
   if(!m_pop3ConData->command_succeeded)
     return Error("pop3ServerError");
 
   nsAutoCString command("AUTH" CRLF);
 
   m_pop3ConData->next_state_after_response = POP3_AUTH_RESPONSE;
   return Pop3SendData(command.get());
 }
@@ -1386,17 +1400,17 @@ int32_t nsPop3Protocol::AuthResponse(nsI
 
     if(pauseForMoreData || !line)
     {
         m_pop3ConData->pause_for_read = true; /* pause */
         PR_Free(line);
         return(0);
     }
 
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
 
     if (!PL_strcmp(line, "."))
     {
         m_pop3Server->SetPop3CapabilityFlags(m_pop3ConData->capability_flags);
 
         // now that we've read all the AUTH responses, go for it
         m_pop3ConData->next_state = POP3_SEND_CAPA;
         m_pop3ConData->pause_for_read = false; /* don't pause */
@@ -1419,17 +1433,17 @@ int32_t nsPop3Protocol::AuthResponse(nsI
 }
 
 /*
  * POP3 CAPA extension, see RFC 2449, chapter 5
  */
 
 int32_t nsPop3Protocol::SendCapa()
 {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("SendCapa()"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("SendCapa()")));
     if(!m_pop3ConData->command_succeeded)
         return Error("pop3ServerError");
 
     nsAutoCString command("CAPA" CRLF);
 
     m_pop3ConData->next_state_after_response = POP3_CAPA_RESPONSE;
     return Pop3SendData(command.get());
 }
@@ -1457,17 +1471,17 @@ int32_t nsPop3Protocol::CapaResponse(nsI
 
     if(pauseForMoreData || !line)
     {
         m_pop3ConData->pause_for_read = true; /* pause */
         PR_Free(line);
         return(0);
     }
 
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
 
     if (!PL_strcmp(line, "."))
     {
         // now that we've read all the CAPA responses, go for it
         m_pop3ConData->next_state = POP3_PROCESS_AUTH;
         m_pop3ConData->pause_for_read = false; /* don't pause */
     }
     else
@@ -1521,17 +1535,17 @@ int32_t nsPop3Protocol::CapaResponse(nsI
 
         if (responseLine.Find("MSN", CaseInsensitiveCompare) >= 0)
           SetCapFlag(POP3_HAS_AUTH_NTLM|POP3_HAS_AUTH_MSN);
 
         m_pop3Server->SetPop3CapabilityFlags(m_pop3ConData->capability_flags);
     }
 
     PR_Free(line);
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("capa processed"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("Capability entry processed")));
     return 0;
 }
 
 int32_t nsPop3Protocol::SendTLSResponse()
 {
   // only tear down our existing connection and open a new one if we received
   // a +OK response from the pop server after we issued the STLS command
   nsresult rv = NS_OK;
@@ -1608,17 +1622,17 @@ void nsPop3Protocol::InitPrefAuthMethods
       m_prefAuthMethods = POP3_HAS_AUTH_APOP |
           POP3_HAS_AUTH_CRAM_MD5 | POP3_HAS_AUTH_GSSAPI |
           POP3_HAS_AUTH_NTLM | POP3_HAS_AUTH_MSN;
       break;
     default:
       NS_ASSERTION(false, "POP: authMethod pref invalid");
       // TODO log to error console
       MOZ_LOG(POP3LOGMODULE, LogLevel::Error,
-          ("POP: bad pref authMethod = %d\n", authMethodPrefValue));
+              (POP3LOG("POP: bad pref authMethod = %d\n"), authMethodPrefValue));
       // fall to any
     case nsMsgAuthMethod::anything:
       m_prefAuthMethods = POP3_HAS_AUTH_USER |
           POP3_HAS_AUTH_LOGIN | POP3_HAS_AUTH_PLAIN |
           POP3_HAS_AUTH_CRAM_MD5 | POP3_HAS_AUTH_APOP |
           POP3_HAS_AUTH_GSSAPI |
           POP3_HAS_AUTH_NTLM | POP3_HAS_AUTH_MSN;
       // TODO needed?
@@ -1633,24 +1647,24 @@ void nsPop3Protocol::InitPrefAuthMethods
  * which is allowed by server and prefs and not marked failed.
  * The order of preference and trying of auth methods is encoded here.
  */
 nsresult nsPop3Protocol::ChooseAuthMethod()
 {
   int32_t availCaps = GetCapFlags() & m_prefAuthMethods & ~m_failedAuthMethods;
 
   MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
-        ("POP auth: server caps 0x%X, pref 0x%X, failed 0x%X, avail caps 0x%X",
-        GetCapFlags(), m_prefAuthMethods, m_failedAuthMethods, availCaps));
+          (POP3LOG("POP auth: server caps 0x%X, pref 0x%X, failed 0x%X, avail caps 0x%X"),
+           GetCapFlags(), m_prefAuthMethods, m_failedAuthMethods, availCaps));
   MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
-        ("(GSSAPI = 0x%X, CRAM = 0x%X, APOP = 0x%X, NTLM = 0x%X, "
-        "MSN =  0x%X, PLAIN = 0x%X, LOGIN = 0x%X, USER/PASS = 0x%X)",
-        POP3_HAS_AUTH_GSSAPI, POP3_HAS_AUTH_CRAM_MD5, POP3_HAS_AUTH_APOP,
-        POP3_HAS_AUTH_NTLM, POP3_HAS_AUTH_MSN, POP3_HAS_AUTH_PLAIN,
-        POP3_HAS_AUTH_LOGIN, POP3_HAS_AUTH_USER));
+          (POP3LOG("(GSSAPI = 0x%X, CRAM = 0x%X, APOP = 0x%X, NTLM = 0x%X, "
+           "MSN =  0x%X, PLAIN = 0x%X, LOGIN = 0x%X, USER/PASS = 0x%X)"),
+           POP3_HAS_AUTH_GSSAPI, POP3_HAS_AUTH_CRAM_MD5, POP3_HAS_AUTH_APOP,
+           POP3_HAS_AUTH_NTLM, POP3_HAS_AUTH_MSN, POP3_HAS_AUTH_PLAIN,
+           POP3_HAS_AUTH_LOGIN, POP3_HAS_AUTH_USER));
 
   if (POP3_HAS_AUTH_GSSAPI & availCaps)
     m_currentAuthMethod = POP3_HAS_AUTH_GSSAPI;
   else if (POP3_HAS_AUTH_CRAM_MD5 & availCaps)
     m_currentAuthMethod = POP3_HAS_AUTH_CRAM_MD5;
   else if (POP3_HAS_AUTH_APOP & availCaps)
     m_currentAuthMethod = POP3_HAS_AUTH_APOP;
   else if (POP3_HAS_AUTH_NTLM & availCaps)
@@ -1662,49 +1676,50 @@ nsresult nsPop3Protocol::ChooseAuthMetho
   else if (POP3_HAS_AUTH_LOGIN & availCaps)
     m_currentAuthMethod = POP3_HAS_AUTH_LOGIN;
   else if (POP3_HAS_AUTH_USER & availCaps)
     m_currentAuthMethod = POP3_HAS_AUTH_USER;
   else
   {
     // there are no matching login schemes at all, per server and prefs
     m_currentAuthMethod = POP3_AUTH_MECH_UNDEFINED;
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("no auth method remaining"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("no auth method remaining")));
     return NS_ERROR_FAILURE;
   }
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("trying auth method 0x%X", m_currentAuthMethod));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
+          (POP3LOG("trying auth method 0x%X"), m_currentAuthMethod));
   return NS_OK;
 }
 
 void nsPop3Protocol::MarkAuthMethodAsFailed(int32_t failedAuthMethod)
 {
   MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
-      ("marking auth method 0x%X failed", failedAuthMethod));
+          (POP3LOG("marking auth method 0x%X failed"), failedAuthMethod));
   m_failedAuthMethods |= failedAuthMethod;
 }
 
 /**
  * Start over, trying all auth methods again
  */
 void nsPop3Protocol::ResetAuthMethods()
 {
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("resetting (failed) auth methods"));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("resetting (failed) auth methods")));
   m_currentAuthMethod = POP3_AUTH_MECH_UNDEFINED;
   m_failedAuthMethods = 0;
 }
 
 /**
  * state POP3_PROCESS_AUTH
  * Called when we should try to authenticate to the server.
  * Also called when one auth method fails and we want to try and start
  * the next best auth method.
  */
 int32_t nsPop3Protocol::ProcessAuth()
 {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("ProcessAuth()"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("ProcessAuth()")));
 
     // Try to upgrade to STARTTLS -- TODO move into its own function
     if (!m_tlsEnabled)
     {
       if(TestCapFlag(POP3_HAS_STLS))
       {
         if (m_socketType == nsMsgSocketType::trySTARTTLS ||
             m_socketType == nsMsgSocketType::alwaysSTARTTLS)
@@ -1724,17 +1739,17 @@ int32_t nsPop3Protocol::ProcessAuth()
 
     m_password_already_sent = false;
 
     nsresult rv = ChooseAuthMethod();
     if (NS_FAILED(rv))
     {
       // Pref doesn't match server. Now, find an appropriate error msg.
       MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
-           ("ProcessAuth() early exit because no auth methods"));
+              (POP3LOG("ProcessAuth() early exit because no auth methods")));
 
       // AuthGSSAPI* falls in here in case of an auth failure.
       // If Kerberos was the only method, assume that
       // the user is just not logged in yet, and show an appropriate error.
       if (m_prefAuthMethods == POP3_HAS_AUTH_GSSAPI &&
           m_failedAuthMethods == POP3_HAS_AUTH_GSSAPI)
         return Error("pop3GssapiFailure");
 
@@ -1762,83 +1777,83 @@ int32_t nsPop3Protocol::ProcessAuth()
       else
         // just "change auth method"
         return Error("pop3AuthMechNotSupported");
     }
 
     switch (m_currentAuthMethod)
     {
       case POP3_HAS_AUTH_GSSAPI:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP GSSAPI"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP GSSAPI")));
         m_pop3ConData->next_state = POP3_AUTH_GSSAPI;
         break;
       case POP3_HAS_AUTH_APOP:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP APOP"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP APOP")));
         m_pop3ConData->next_state = POP3_SEND_PASSWORD;
         break;
       case POP3_HAS_AUTH_CRAM_MD5:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP CRAM"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP CRAM")));
       case POP3_HAS_AUTH_PLAIN:
       case POP3_HAS_AUTH_USER:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP username"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP username")));
         m_pop3ConData->next_state = POP3_SEND_USERNAME;
         break;
       case POP3_HAS_AUTH_LOGIN:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP AUTH=LOGIN"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP AUTH=LOGIN")));
         m_pop3ConData->next_state = POP3_AUTH_LOGIN;
         break;
       case POP3_HAS_AUTH_NTLM:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP NTLM"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP NTLM")));
         m_pop3ConData->next_state = POP3_AUTH_NTLM;
         break;
       case POP3_HAS_AUTH_NONE:
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("POP no auth"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("POP no auth")));
         m_pop3ConData->command_succeeded = true;
         m_pop3ConData->next_state = POP3_NEXT_AUTH_STEP;
         break;
       default:
         MOZ_LOG(POP3LOGMODULE, LogLevel::Error,
-             ("POP: m_currentAuthMethod has unknown value"));
+                (POP3LOG("POP: m_currentAuthMethod has unknown value")));
         return Error("pop3AuthMechNotSupported");
     }
 
     m_pop3ConData->pause_for_read = false;
 
     return 0;
 }
 
 /**
  * state POP3_NEXT_AUTH_STEP
  * This is called when we finished one auth step (e.g. sending username
  * or password are separate steps, similarly for AUTH LOGIN, NTLM etc.)
  * and want to proceed to the next one.
  */
 int32_t nsPop3Protocol::NextAuthStep()
 {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("NextAuthStep()"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("NextAuthStep()")));
     if (m_pop3ConData->command_succeeded)
     {
         if (m_password_already_sent || // (also true for GSSAPI)
             m_currentAuthMethod == POP3_HAS_AUTH_NONE)
         {
-            MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("login succeeded"));
+            MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("login succeeded")));
             m_nsIPop3Sink->SetUserAuthenticated(true);
             ClearFlag(POP3_PASSWORD_FAILED);
             if (m_pop3ConData->verify_logon)
               m_pop3ConData->next_state = POP3_SEND_QUIT;
             else
               m_pop3ConData->next_state = (m_pop3ConData->get_url)
                                           ? POP3_SEND_GURL : POP3_SEND_STAT;
         }
         else
             m_pop3ConData->next_state = POP3_SEND_PASSWORD;
     }
     else
     {
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("command did not succeed"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("command did not succeed")));
         // response code received shows that login failed not because of
         // wrong credential -> stop login without retry or pw dialog, only alert
         // parameter list -> user
         nsCString userName;
         nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
         nsresult rv = server->GetRealUsername(userName);
         NS_ENSURE_SUCCESS(rv, -1);
         NS_ConvertUTF8toUTF16 userNameUTF16(userName);
@@ -1850,60 +1865,60 @@ int32_t nsPop3Protocol::NextAuthStep()
 
           return Error("pop3UsernameFailure");
         }
         // response code received shows that server is certain about the
         // credential was wrong -> no fallback, show alert and pw dialog
         if (TestFlag(POP3_AUTH_FAILURE))
         {
             MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
-               ("auth failure, setting password failed"));
+                    (POP3LOG("auth failure, setting password failed")));
             if (m_password_already_sent)
               Error("pop3PasswordFailed", params, 1);
             else
               Error("pop3UsernameFailure");
             SetFlag(POP3_PASSWORD_FAILED);
             ClearFlag(POP3_AUTH_FAILURE);
             return 0;
         }
 
         // We have no certain response code -> fallback and try again.
         // Mark the auth method failed, to use a different method next round.
         MarkAuthMethodAsFailed(m_currentAuthMethod);
 
         if (m_currentAuthMethod == POP3_HAS_AUTH_USER &&
             !m_password_already_sent)
         {
-            MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("USER username failed"));
+            MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("USER username failed")));
             // if USER auth method failed before sending the password,
             // the username was wrong.
             // no fallback but return error
             return Error("pop3UsernameFailure");
         }
 
         // If we have no auth method left, ask user to try with new password
         rv = ChooseAuthMethod();
         if (NS_FAILED(rv))
         {
             MOZ_LOG(POP3LOGMODULE, LogLevel::Error,
-                ("POP: no auth methods remaining, setting password failure"));
+                    (POP3LOG("POP: no auth methods remaining, setting password failure")));
             /* Sever the connection and go back to the `read password' state,
                which, upon success, will re-open the connection.  Set a flag
                which causes the prompt to be different that time (to indicate
                that the old password was bogus.)
 
                But if we're just checking for new mail (biff) then don't bother
                prompting the user for a password: just fail silently.
             */
             SetFlag(POP3_PASSWORD_FAILED);
             Error("pop3PasswordFailed", params, 1);
             return 0;
         }
         MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
-           ("still have some auth methods to try"));
+                (POP3LOG("still have some auth methods to try")));
 
         // TODO needed?
         //m_pop3Server->SetPop3CapabilityFlags(m_pop3ConData->capability_flags);
 
         m_pop3ConData->command_succeeded = true;
 
         m_pop3ConData->next_state = POP3_PROCESS_AUTH;
     }
@@ -1979,17 +1994,17 @@ int32_t nsPop3Protocol::AuthNtlmResponse
 
     m_pop3ConData->pause_for_read = false;
 
     return 0;
 }
 
 int32_t nsPop3Protocol::AuthGSSAPI()
 {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("AuthGSSAPI()"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("AuthGSSAPI()")));
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
     if (server) {
         nsAutoCString cmd;
         nsAutoCString service("pop@");
         nsCString hostName;
         nsresult rv;
         server->GetRealHostName(hostName);
         service.Append(hostName);
@@ -2027,34 +2042,34 @@ int32_t nsPop3Protocol::AuthGSSAPIRespon
 
     if (first) {
         m_GSSAPICache += CRLF;
         result = Pop3SendData(m_GSSAPICache.get());
         m_GSSAPICache.Truncate();
     }
     else {
         nsAutoCString cmd;
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("GSSAPI step 2"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("GSSAPI step 2")));
         nsresult rv = DoGSSAPIStep2(m_commandResponse, cmd);
         if (NS_FAILED(rv))
             cmd = "*";
         if (rv == NS_SUCCESS_AUTH_FINISHED) {
             m_pop3ConData->next_state_after_response = POP3_NEXT_AUTH_STEP;
             m_password_already_sent = true;
         }
         cmd += CRLF;
         result = Pop3SendData(cmd.get());
     }
 
     return result;
 }
 
 int32_t nsPop3Protocol::SendUsername()
 {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("SendUsername()"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("SendUsername()")));
     if(m_username.IsEmpty())
       return Error("pop3UsernameUndefined");
 
     // <copied from="SendPassword()">
     // Needed for NTLM
 
     // The POP3_SEND_PASSWORD/POP3_WAIT_SEND_PASSWORD states have already
     // got the password - they will have cancelled if necessary.
@@ -2077,40 +2092,40 @@ int32_t nsPop3Protocol::SendUsername()
     else if (m_currentAuthMethod == POP3_HAS_AUTH_LOGIN)
     {
         char *base64Str = PL_Base64Encode(m_username.get(), m_username.Length(), nullptr);
         cmd = base64Str;
         PR_Free(base64Str);
     }
     else if (m_currentAuthMethod == POP3_HAS_AUTH_USER)
     {
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("USER login"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("USER login")));
         cmd = "USER ";
         cmd += m_username;
     }
     else
     {
       MOZ_LOG(POP3LOGMODULE, LogLevel::Error,
-          ("In nsPop3Protocol::SendUsername(), m_currentAuthMethod is 0x%X, "
-          "but that is unexpected", m_currentAuthMethod));
+              (POP3LOG("In nsPop3Protocol::SendUsername(), m_currentAuthMethod is 0x%X, "
+                       "but that is unexpected"), m_currentAuthMethod));
       return Error("pop3AuthInternalError");
     }
 
     cmd += CRLF;
 
     m_pop3ConData->next_state_after_response = POP3_NEXT_AUTH_STEP;
 
     m_pop3ConData->pause_for_read = true;
 
     return Pop3SendData(cmd.get());
 }
 
 int32_t nsPop3Protocol::SendPassword()
 {
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("SendPassword()"));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("SendPassword()")));
   if (m_username.IsEmpty())
     return Error("pop3UsernameUndefined");
 
   // <copied to="SendUsername()">
   // Needed here, too, because APOP skips SendUsername()
   // The POP3_SEND_PASSWORD/POP3_WAIT_SEND_PASSWORD states have already
   // got the password - they will have cancelled if necessary.
   // If the password is still empty here, don't try to go on.
@@ -2123,17 +2138,17 @@ int32_t nsPop3Protocol::SendPassword()
 
   nsAutoCString cmd;
   nsresult rv;
 
   if (m_currentAuthMethod == POP3_HAS_AUTH_NTLM)
     rv = DoNtlmStep2(m_commandResponse, cmd);
   else if (m_currentAuthMethod == POP3_HAS_AUTH_CRAM_MD5)
   {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("CRAM login"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("CRAM login")));
     char buffer[512]; // TODO nsAutoCString
     unsigned char digest[DIGEST_LENGTH];
 
     char *decodedChallenge = PL_Base64Decode(m_commandResponse.get(),
     m_commandResponse.Length(), nullptr);
 
     if (decodedChallenge)
       rv = MSGCramMD5(decodedChallenge, strlen(decodedChallenge),
@@ -2159,17 +2174,17 @@ int32_t nsPop3Protocol::SendPassword()
       PR_Free(base64Str);
     }
 
     if (NS_FAILED(rv))
       cmd = "*";
   }
   else if (m_currentAuthMethod == POP3_HAS_AUTH_APOP)
   {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("APOP login"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("APOP login")));
     char buffer[512];
     unsigned char digest[DIGEST_LENGTH];
 
     rv = MSGApopMD5(m_ApopTimestamp.get(), m_ApopTimestamp.Length(),
                     m_passwordResult.get(), m_passwordResult.Length(), digest);
 
     if (NS_SUCCEEDED(rv))
     {
@@ -2187,17 +2202,17 @@ int32_t nsPop3Protocol::SendPassword()
       cmd = buffer;
     }
 
     if (NS_FAILED(rv))
       cmd = "*";
   }
   else if (m_currentAuthMethod == POP3_HAS_AUTH_PLAIN)
   {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("PLAIN login"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("PLAIN login")));
     // workaround for IPswitch's IMail server software
     // this server goes into LOGIN mode even if we send "AUTH PLAIN"
     // "VXNlc" is the beginning of the base64 encoded prompt ("Username:") for LOGIN
     if (StringBeginsWith(m_commandResponse, NS_LITERAL_CSTRING("VXNlc")))
     {
       // disable PLAIN and enable LOGIN (in case it's not already enabled)
       ClearCapFlag(POP3_HAS_AUTH_PLAIN);
       SetCapFlag(POP3_HAS_AUTH_LOGIN);
@@ -2219,34 +2234,34 @@ int32_t nsPop3Protocol::SendPassword()
     len += m_passwordResult.Length();
 
     char *base64Str = PL_Base64Encode(plain_string, len, nullptr);
     cmd = base64Str;
     PR_Free(base64Str);
   }
   else if (m_currentAuthMethod == POP3_HAS_AUTH_LOGIN)
   {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("LOGIN password"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("LOGIN password")));
     char * base64Str =
         PL_Base64Encode(m_passwordResult.get(), m_passwordResult.Length(),
                         nullptr);
     cmd = base64Str;
     PR_Free(base64Str);
   }
   else if (m_currentAuthMethod == POP3_HAS_AUTH_USER)
   {
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("PASS password"));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("PASS password")));
     cmd = "PASS ";
     cmd += m_passwordResult;
   }
   else
   {
     MOZ_LOG(POP3LOGMODULE, LogLevel::Error,
-        ("In nsPop3Protocol::SendPassword(), m_currentAuthMethod is %X, "
-        "but that is unexpected", m_currentAuthMethod));
+            (POP3LOG("In nsPop3Protocol::SendPassword(), m_currentAuthMethod is %X, "
+                     "but that is unexpected"), m_currentAuthMethod));
     return Error("pop3AuthInternalError");
   }
 
   cmd += CRLF;
 
   // TODO needed?
   //m_pop3Server->SetPop3CapabilityFlags(m_pop3ConData->capability_flags);
 
@@ -2460,17 +2475,17 @@ nsPop3Protocol::GetList(nsIInputStream* 
 
   if (pauseForMoreData || !line)
   {
     m_pop3ConData->pause_for_read = true;
     PR_Free(line);
     return(ln);
   }
 
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
 
   /* parse the line returned from the list command
   * it looks like
   * #msg_number #bytes
   *
   * list data is terminated by a ".CRLF" line
   */
   if (!PL_strcmp(line, "."))
@@ -2630,17 +2645,17 @@ nsPop3Protocol::GetXtndXlstMsgid(nsIInpu
 
   if (pauseForMoreData || !line)
   {
     m_pop3ConData->pause_for_read = true;
     PR_Free(line);
     return ln;
   }
 
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
 
   /* parse the line returned from the list command
   * it looks like
   * 1 Message-ID: <3117E4DC.2699@example.com>
   *
   * list data is terminated by a ".CRLF" line
   */
   if (!PL_strcmp(line, "."))
@@ -2746,17 +2761,17 @@ int32_t nsPop3Protocol::GetUidlList(nsII
 
     if (pauseForMoreData || !line)
     {
       PR_Free(line);
       m_pop3ConData->pause_for_read = true;
       return ln;
     }
 
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
 
     /* parse the line returned from the list command
      * it looks like
      * #msg_number uidl
      *
      * list data is terminated by a ".CRLF" line
      */
     if (!PL_strcmp(line, "."))
@@ -3239,37 +3254,37 @@ nsPop3Protocol::RetrResponse(nsIInputStr
 
         m_pop3ConData->parsed_bytes = 0;
         m_pop3ConData->pop3_size = m_pop3ConData->cur_msg_size;
         m_pop3ConData->assumed_end = false;
 
         m_pop3Server->GetDotFix(&m_pop3ConData->dot_fix);
 
         MOZ_LOG(POP3LOGMODULE,LogLevel::Info,
-               ("Opening message stream: MSG_IncorporateBegin"));
+                (POP3LOG("Opening message stream: MSG_IncorporateBegin")));
 
         /* open the message stream so we have someplace
          * to put the data
          */
         m_pop3ConData->real_new_counter++;
         /* (rb) count only real messages being downloaded */
         rv = m_nsIPop3Sink->IncorporateBegin(uidl, m_url, flags,
                                         &m_pop3ConData->msg_closure);
 
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Info, ("Done opening message stream!"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("Done opening message stream!")));
 
         if(!m_pop3ConData->msg_closure || NS_FAILED(rv))
             return Error("pop3MessageWriteError");
     }
 
     m_pop3ConData->pause_for_read = true;
 
     bool pauseForMoreData = false;
     char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv, true);
-    MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
     if (NS_FAILED(rv))
       return -1;
 
     buffer_size = status;
 
     if (status == 0 && !line)  // no bytes read in...
       return (0);
 
@@ -3294,17 +3309,17 @@ nsPop3Protocol::RetrResponse(nsIInputStr
 
         // now read in the next line
         PR_Free(line);
         line = m_lineStreamBuffer->ReadNextLine(inputStream, buffer_size,
                                                 pauseForMoreData, &rv, true);
         if (NS_FAILED(rv))
           return -1;
 
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Info,("RECV: %s", line));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
         // buffer_size already includes MSG_LINEBREAK_LEN so
         // subtract and add CRLF
         // but not really sure we always had CRLF in input since
         // we also treat a single LF as line ending!
         status += buffer_size - MSG_LINEBREAK_LEN + 2;
       } while (line);
     }
 
@@ -3662,32 +3677,32 @@ nsPop3Protocol::CommitState(bool remove_
  */
 nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aInputStream,
                                               uint64_t sourceOffset, uint32_t aLength)
 {
   int32_t status = 0;
   bool urlStatusSet = false;
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_url);
 
-  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, ("Entering NET_ProcessPop3 %d",
-    aLength));
+  MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("Entering NET_ProcessPop3 %d"),
+                                          aLength));
 
   m_pop3ConData->pause_for_read = false; /* already paused; reset */
 
   if(m_username.IsEmpty())
   {
     // net_pop3_block = false;
     Error("pop3UsernameUndefined");
     return NS_MSG_SERVER_USERNAME_MISSING;
   }
 
   while(!m_pop3ConData->pause_for_read)
   {
     MOZ_LOG(POP3LOGMODULE, LogLevel::Info,
-      ("POP3: Entering state: %d", m_pop3ConData->next_state));
+            (POP3LOG("Entering state: %d"), m_pop3ConData->next_state));
 
     switch(m_pop3ConData->next_state)
     {
     case POP3_READ_PASSWORD:
       // This is a separate state so that we're waiting for the user to type
       // in a password while we don't actually have a connection to the pop
       // server open; this saves us from having to worry about the server
       // timing out on us while we wait for user input.
@@ -4024,17 +4039,18 @@ nsresult nsPop3Protocol::ProcessProtocol
         // no msgWindow means no re-prompt, so treat as error.
         if (TestFlag(POP3_PASSWORD_FAILED) && msgWindow)
         {
           // We get here because the password was wrong.
           if (!m_socketIsOpen && mailnewsurl)
           {
             // The server dropped the connection, so we're going
             // to re-run the url.
-            MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("need to rerun url because connection dropped during auth"));
+            MOZ_LOG(POP3LOGMODULE, LogLevel::Debug,
+                    (POP3LOG("need to rerun url because connection dropped during auth")));
             m_needToRerunUrl = true;
             return NS_OK;
           }
           m_pop3ConData->next_state = POP3_READ_PASSWORD;
           m_pop3ConData->command_succeeded = true;
           status = 0;
           break;
         }
@@ -4048,20 +4064,20 @@ nsresult nsPop3Protocol::ProcessProtocol
       break;
 
     case POP3_FREE:
       {
         UpdateProgressPercent(0,0); // clear out the progress meter
         nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
         if (server)
         {
-          MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("Clearing server busy in POP3_FREE"));
+          MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("Clearing server busy in POP3_FREE")));
           server->SetServerBusy(false); // the server is now not busy
         }
-        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, ("Clearing running protocol in POP3_FREE"));
+        MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("Clearing running protocol in POP3_FREE")));
         CloseSocket();
         m_pop3Server->SetRunningProtocol(nullptr);
         if (mailnewsurl && urlStatusSet)
           mailnewsurl->SetUrlState(false, m_pop3ConData->urlStatus);
 
         m_url = nullptr;
         return NS_OK;
       }
--- a/mailnews/local/src/nsPop3Sink.cpp
+++ b/mailnews/local/src/nsPop3Sink.cpp
@@ -34,16 +34,17 @@
 #include "nsMsgUtils.h"
 #include "nsMsgBaseCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPop3Service.h"
 #include "nsMsgLocalCID.h"
 #include "mozilla/Services.h"
 
 extern PRLogModuleInfo *POP3LOGMODULE;
+#define POP3LOG(str) "%s sink: [this=%p] " str, POP3LOGMODULE->name, this
 
 NS_IMPL_ISUPPORTS(nsPop3Sink, nsIPop3Sink)
 
 nsPop3Sink::nsPop3Sink()
 {
     m_authed = false;
     m_downloadingToTempFile = false;
     m_biffState = 0;
@@ -55,17 +56,18 @@ nsPop3Sink::nsPop3Sink()
     m_uidlDownload = false;
     m_buildMessageUri = false;
     if (!POP3LOGMODULE)
       POP3LOGMODULE = PR_NewLogModule("POP3");
 }
 
 nsPop3Sink::~nsPop3Sink()
 {
-    MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug, ("Calling ReleaseFolderLock from ~nsPop3Sink"));
+    MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug,
+            (POP3LOG("Calling ReleaseFolderLock from ~nsPop3Sink")));
     ReleaseFolderLock();
 }
 
 nsresult
 nsPop3Sink::SetUserAuthenticated(bool authed)
 {
   m_authed = authed;
   m_popServer->SetAuthenticated(authed);
@@ -223,22 +225,24 @@ nsPop3Sink::BeginMailDelivery(bool uidlD
   if (account)
     account->GetKey(m_accountKey);
 
   bool isLocked;
   nsCOMPtr <nsISupports> supports = do_QueryInterface(static_cast<nsIPop3Sink*>(this));
   m_folder->GetLocked(&isLocked);
   if(!isLocked)
   {
-    MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug, ("BeginMailDelivery acquiring semaphore"));
+    MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug,
+            (POP3LOG("BeginMailDelivery acquiring semaphore")));
     m_folder->AcquireSemaphore(supports);
   }
   else
   {
-    MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug, ("BeginMailDelivery folder locked"));
+    MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug,
+            (POP3LOG("BeginMailDelivery folder locked")));
     return NS_MSG_FOLDER_BUSY;
   }
   m_uidlDownload = uidlDownload;
   if (!uidlDownload)
     FindPartialMessages();
 
   m_folder->GetNumNewMessages(false, &m_numNewMessagesInFolder);
 
@@ -273,17 +277,18 @@ nsPop3Sink::EndMailDelivery(nsIPop3Proto
 
   if (m_downloadingToTempFile)
     m_tmpDownloadFile->Remove(false);
 
   // tell the parser to mark the db valid *after* closing the mailbox.
   if (m_newMailParser)
     m_newMailParser->UpdateDBFolderInfo();
 
-  MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug, ("Calling ReleaseFolderLock from EndMailDelivery"));
+  MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug,
+          (POP3LOG("Calling ReleaseFolderLock from EndMailDelivery")));
   nsresult rv = ReleaseFolderLock();
   NS_ASSERTION(NS_SUCCEEDED(rv),"folder lock not released successfully");
 
   bool filtersRun;
   m_folder->CallFilterPlugins(nullptr, &filtersRun); // ??? do we need msgWindow?
   int32_t numNewMessagesInFolder;
   // if filters have marked msgs read or deleted, the num new messages count
   // will go negative by the number of messages marked read or deleted,
@@ -372,17 +377,18 @@ nsresult
 nsPop3Sink::ReleaseFolderLock()
 {
   nsresult result = NS_OK;
   if (!m_folder)
     return result;
   bool haveSemaphore;
   nsCOMPtr <nsISupports> supports = do_QueryInterface(static_cast<nsIPop3Sink*>(this));
   result = m_folder->TestSemaphore(supports, &haveSemaphore);
-  MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug, ("ReleaseFolderLock haveSemaphore = %s", haveSemaphore ? "TRUE" : "FALSE"));
+  MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug,
+          (POP3LOG("ReleaseFolderLock haveSemaphore = %s"), haveSemaphore ? "TRUE" : "FALSE"));
 
   if(NS_SUCCEEDED(result) && haveSemaphore)
     result = m_folder->ReleaseSemaphore(supports);
   return result;
 }
 
 nsresult
 nsPop3Sink::AbortMailDelivery(nsIPop3Protocol *protocol)
@@ -399,17 +405,18 @@ nsPop3Sink::AbortMailDelivery(nsIPop3Pro
 
   if (m_downloadingToTempFile && m_tmpDownloadFile)
     m_tmpDownloadFile->Remove(false);
 
   /* tell the parser to mark the db valid *after* closing the mailbox.
   we have truncated the inbox, so berkeley mailbox and msf file are in sync*/
   if (m_newMailParser)
     m_newMailParser->UpdateDBFolderInfo();
-  MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug, ("Calling ReleaseFolderLock from AbortMailDelivery"));
+  MOZ_LOG(POP3LOGMODULE, mozilla::LogLevel::Debug,
+          (POP3LOG("Calling ReleaseFolderLock from AbortMailDelivery")));
 
   nsresult rv = ReleaseFolderLock();
   NS_ASSERTION(NS_SUCCEEDED(rv),"folder lock not released successfully");
 
 #ifdef DEBUG
     printf("Abort mail message delivery.\n");
 #endif
   nsCOMPtr<nsIPop3Service> pop3Service(do_GetService(NS_POP3SERVICE_CONTRACTID1, &rv));