Backed out 2 changesets (bug 1162336) for breaking at least windows builds
authorWes Kocher <wkocher@mozilla.com>
Thu, 07 May 2015 11:13:24 -0700
changeset 242863 a74ede09893fc7cb4a6fa1dbbac0c758595aa3bb
parent 242862 4127a3c0300b4f84e2efabeb1e2431fe530f6dca
child 242864 ddab177fd4c4877ce7ff372666558aab25138947
push idunknown
push userunknown
push dateunknown
bugs1162336
milestone40.0a1
backs out8952a7fa40507660721df603fdf05434a318140d
0170a6c2a5bebc37e2ca4c92110dbad6784fbc57
Backed out 2 changesets (bug 1162336) for breaking at least windows builds Backed out changeset 8952a7fa4050 (bug 1162336) Backed out changeset 0170a6c2a5be (bug 1162336)
netwerk/base/BackgroundFileSaver.cpp
netwerk/base/Predictor.cpp
netwerk/base/nsAsyncRedirectVerifyHelper.cpp
netwerk/base/nsAsyncStreamCopier.cpp
netwerk/base/nsAutodialWin.cpp
netwerk/base/nsChannelClassifier.cpp
netwerk/base/nsDirectoryIndexStream.cpp
netwerk/base/nsInputStreamPump.cpp
netwerk/base/nsLoadGroup.cpp
netwerk/base/nsPACMan.cpp
netwerk/base/nsProtocolProxyService.cpp
netwerk/base/nsRequestObserverProxy.cpp
netwerk/base/nsSocketTransport2.cpp
netwerk/base/nsSocketTransportService2.cpp
netwerk/base/nsSocketTransportService2.h
netwerk/base/nsStandardURL.cpp
netwerk/cache/nsCache.cpp
netwerk/cache/nsCache.h
netwerk/cache/nsCacheService.cpp
netwerk/cache/nsCacheService.h
netwerk/cache/nsDiskCacheDevice.cpp
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFileContextEvictor.cpp
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
netwerk/cache2/CacheLog.cpp
netwerk/cache2/CacheLog.h
netwerk/cache2/CacheStorageService.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/dns/GetAddrInfo.cpp
netwerk/dns/nsHostResolver.cpp
netwerk/protocol/ftp/nsFTPChannel.cpp
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/ftp/nsFtpControlConnection.cpp
netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
netwerk/protocol/ftp/nsFtpProtocolHandler.h
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpLog.h
netwerk/protocol/http/nsHttp.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpNTLMAuth.cpp
netwerk/protocol/http/nsHttpTransaction.cpp
netwerk/protocol/res/nsResProtocolHandler.cpp
netwerk/protocol/rtsp/controller/RtspControllerChild.cpp
netwerk/protocol/rtsp/controller/RtspControllerParent.cpp
netwerk/protocol/websocket/BaseWebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannelParent.cpp
netwerk/protocol/websocket/WebSocketLog.h
netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
netwerk/protocol/wyciwyg/nsWyciwyg.cpp
netwerk/protocol/wyciwyg/nsWyciwyg.h
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/sctp/datachannel/DataChannelLog.h
netwerk/socket/nsSOCKSIOLayer.cpp
netwerk/streamconv/converters/nsFTPDirListingConv.cpp
netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
netwerk/system/win32/nsNotifyAddrListener.cpp
netwerk/test/TestBlockingSocket.cpp
netwerk/test/TestIOThreads.cpp
netwerk/test/TestOverlappedIO.cpp
netwerk/test/TestProtocols.cpp
netwerk/test/TestServ.cpp
netwerk/test/TestSocketIO.cpp
netwerk/test/TestSocketTransport.cpp
netwerk/test/TestStreamChannel.cpp
netwerk/test/TestStreamLoader.cpp
netwerk/test/TestStreamPump.cpp
netwerk/test/TestStreamTransport.cpp
netwerk/test/TestUpload.cpp
netwerk/wifi/nsWifiAccessPoint.cpp
netwerk/wifi/nsWifiMonitor.cpp
netwerk/wifi/nsWifiMonitor.h
netwerk/wifi/nsWifiMonitorGonk.cpp
--- a/netwerk/base/BackgroundFileSaver.cpp
+++ b/netwerk/base/BackgroundFileSaver.cpp
@@ -28,19 +28,24 @@
 #include <softpub.h>
 #include <wintrust.h>
 #endif // XP_WIN
 
 namespace mozilla {
 namespace net {
 
 // NSPR_LOG_MODULES=BackgroundFileSaver:5
+#if defined(PR_LOGGING)
 PRLogModuleInfo *BackgroundFileSaver::prlog = nullptr;
 #define LOG(args) PR_LOG(BackgroundFileSaver::prlog, PR_LOG_DEBUG, args)
 #define LOG_ENABLED() PR_LOG_TEST(BackgroundFileSaver::prlog, 4)
+#else
+#define LOG(args)
+#define LOG_ENABLED() (false)
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Globals
 
 /**
  * Buffer size for writing to the output file or reading from the input file.
  */
 #define BUFFERED_IO_SIZE (1024 * 32)
@@ -105,18 +110,20 @@ BackgroundFileSaver::BackgroundFileSaver
 , mRenamedTargetKeepPartial(false)
 , mAsyncCopyContext(nullptr)
 , mSha256Enabled(false)
 , mSignatureInfoEnabled(false)
 , mActualTarget(nullptr)
 , mActualTargetKeepPartial(false)
 , mDigestContext(nullptr)
 {
+#if defined(PR_LOGGING)
   if (!prlog)
     prlog = PR_NewLogModule("BackgroundFileSaver");
+#endif
   LOG(("Created BackgroundFileSaver [this = %p]", this));
 }
 
 BackgroundFileSaver::~BackgroundFileSaver()
 {
   LOG(("Destroying BackgroundFileSaver [this = %p]", this));
   nsNSSShutDownPreventionLock lock;
   if (isAlreadyShutDown()) {
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -48,18 +48,22 @@ static const int32_t ANDROID_23_VERSION 
 
 using namespace mozilla;
 
 namespace mozilla {
 namespace net {
 
 Predictor *Predictor::sSelf = nullptr;
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gPredictorLog = nullptr;
 #define PREDICTOR_LOG(args) PR_LOG(gPredictorLog, 4, args)
+#else
+#define PREDICTOR_LOG(args)
+#endif
 
 #define RETURN_IF_FAILED(_rv) \
   do { \
     if (NS_FAILED(_rv)) { \
       return; \
     } \
   } while (0)
 
@@ -306,17 +310,19 @@ Predictor::Predictor()
   ,mSubresourceDegradationYear(PREDICTOR_SUB_DELTA_YEAR_DEFAULT)
   ,mSubresourceDegradationMax(PREDICTOR_SUB_DELTA_MAX_DEFAULT)
   ,mPreconnectMinConfidence(PRECONNECT_MIN_DEFAULT)
   ,mPreresolveMinConfidence(PRERESOLVE_MIN_DEFAULT)
   ,mRedirectLikelyConfidence(REDIRECT_LIKELY_DEFAULT)
   ,mMaxResourcesPerEntry(PREDICTOR_MAX_RESOURCES_DEFAULT)
   ,mStartupCount(1)
 {
+#if defined(PR_LOGGING)
   gPredictorLog = PR_NewLogModule("NetworkPredictor");
+#endif
 
   MOZ_ASSERT(!sSelf, "multiple Predictor instances!");
   sSelf = this;
 }
 
 Predictor::~Predictor()
 {
   if (mInitialized)
--- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
+++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp
@@ -9,25 +9,29 @@
 #include "nsNetUtil.h"
 
 #include "nsIOService.h"
 #include "nsIChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 
 #undef LOG
+#ifdef PR_LOGGING
 static PRLogModuleInfo *
 GetRedirectLog()
 {
     static PRLogModuleInfo *sLog;
     if (!sLog)
         sLog = PR_NewLogModule("nsRedirect");
     return sLog;
 }
 #define LOG(args) PR_LOG(GetRedirectLog(), PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 NS_IMPL_ISUPPORTS(nsAsyncRedirectVerifyHelper,
                   nsIAsyncVerifyRedirectCallback,
                   nsIRunnable)
 
 class nsAsyncVerifyRedirectCallbackEvent : public nsRunnable {
 public:
     nsAsyncVerifyRedirectCallbackEvent(nsIAsyncVerifyRedirectCallback *cb,
--- a/netwerk/base/nsAsyncStreamCopier.cpp
+++ b/netwerk/base/nsAsyncStreamCopier.cpp
@@ -8,20 +8,22 @@
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "prlog.h"
 
 using namespace mozilla;
 
 #undef LOG
+#if defined(PR_LOGGING)
 //
 // NSPR_LOG_MODULES=nsStreamCopier:5
 //
 static PRLogModuleInfo *gStreamCopierLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gStreamCopierLog, PR_LOG_DEBUG, args)
 
 /**
  * An event used to perform initialization off the main thread.
  */
 class AsyncApplyBufferingPolicyEvent final: public nsRunnable
 {
 public:
@@ -62,18 +64,20 @@ private:
 nsAsyncStreamCopier::nsAsyncStreamCopier()
     : mLock("nsAsyncStreamCopier.mLock")
     , mMode(NS_ASYNCCOPY_VIA_READSEGMENTS)
     , mChunkSize(nsIOService::gDefaultSegmentSize)
     , mStatus(NS_OK)
     , mIsPending(false)
     , mShouldSniffBuffering(false)
 {
+#if defined(PR_LOGGING)
     if (!gStreamCopierLog)
         gStreamCopierLog = PR_NewLogModule("nsStreamCopier");
+#endif
     LOG(("Creating nsAsyncStreamCopier @%x\n", this));
 }
 
 nsAsyncStreamCopier::~nsAsyncStreamCopier()
 {
     LOG(("Destroying nsAsyncStreamCopier @%x\n", this));
 }
 
--- a/netwerk/base/nsAutodialWin.cpp
+++ b/netwerk/base/nsAutodialWin.cpp
@@ -24,17 +24,19 @@
 //
 //    set NSPR_LOG_MODULES=Autodial:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables PR_LOG_DEBUG level information and places all output in
 // the file nspr.log
 //
 
+#ifdef PR_LOGGING
 static PRLogModuleInfo* gLog = nullptr;
+#endif
 
 #undef LOGD
 #undef LOGE
 #define LOGD(args) PR_LOG(gLog, PR_LOG_DEBUG, args)
 #define LOGE(args) PR_LOG(gLog, PR_LOG_ERROR, args)
 
 // Don't try to dial again within a few seconds of when user pressed cancel.
 #define NO_RETRY_PERIOD_SEC 5
@@ -57,18 +59,20 @@ nsAutodial::~nsAutodial()
 }
 
 
 // Get settings from the OS. These are settings that might change during
 // the OS session. Call Init() again to pick up those changes if required.
 // Returns NS_ERROR_FAILURE if error or NS_OK if success.
 nsresult nsAutodial::Init()
 {
+#ifdef PR_LOGGING
     if (!gLog)
         gLog = PR_NewLogModule("Autodial");
+#endif
 
     mDefaultEntryName[0] = '\0';
     mNumRASConnectionEntries = 0;
     mAutodialBehavior = QueryAutodialBehavior();
     
     // No need to continue in this case.
     if (mAutodialBehavior == AUTODIAL_NEVER)
     {
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -31,32 +31,36 @@
 
 #include "mozilla/Preferences.h"
 
 #include "prlog.h"
 
 using mozilla::ArrayLength;
 using mozilla::Preferences;
 
+#if defined(PR_LOGGING)
 //
 // NSPR_LOG_MODULES=nsChannelClassifier:5
 //
 static PRLogModuleInfo *gChannelClassifierLog;
+#endif
 #undef LOG
 #define LOG(args)     PR_LOG(gChannelClassifierLog, PR_LOG_DEBUG, args)
 
 NS_IMPL_ISUPPORTS(nsChannelClassifier,
                   nsIURIClassifierCallback)
 
 nsChannelClassifier::nsChannelClassifier()
   : mIsAllowListed(false),
     mSuspendedChannel(false)
 {
+#if defined(PR_LOGGING)
     if (!gChannelClassifierLog)
         gChannelClassifierLog = PR_NewLogModule("nsChannelClassifier");
+#endif
 }
 
 nsresult
 nsChannelClassifier::ShouldEnableTrackingProtection(nsIChannel *aChannel,
                                                     bool *result)
 {
     // Should only be called in the parent process.
     MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
--- a/netwerk/base/nsDirectoryIndexStream.cpp
+++ b/netwerk/base/nsDirectoryIndexStream.cpp
@@ -13,17 +13,19 @@
   http://www.mozilla.org/projects/netlib/dirindexformat.html
 
  */
 
 #include "nsEscape.h"
 #include "nsDirectoryIndexStream.h"
 #include "prlog.h"
 #include "prtime.h"
+#ifdef PR_LOGGING
 static PRLogModuleInfo* gLog;
+#endif
 
 #include "nsISimpleEnumerator.h"
 #ifdef THREADSAFE_I18N
 #include "nsCollationCID.h"
 #include "nsICollation.h"
 #include "nsILocale.h"
 #include "nsILocaleService.h"
 #endif
@@ -39,18 +41,20 @@ static PRLogModuleInfo* gLog;
 // behaviour, though. See bug 99382.
 // When this is fixed, #define THREADSAFE_I18N to get this code working
 
 //#define THREADSAFE_I18N
 
 nsDirectoryIndexStream::nsDirectoryIndexStream()
     : mOffset(0), mStatus(NS_OK), mPos(0)
 {
+#ifdef PR_LOGGING
     if (! gLog)
         gLog = PR_NewLogModule("nsDirectoryIndexStream");
+#endif
 
     PR_LOG(gLog, PR_LOG_DEBUG,
            ("nsDirectoryIndexStream[%p]: created", this));
 }
 
 static int compare(nsIFile* aElement1, nsIFile* aElement2, void* aData)
 {
     if (!NS_IsNativeUTF8()) {
@@ -87,23 +91,25 @@ nsDirectoryIndexStream::Init(nsIFile* aD
     nsresult rv;
     bool isDir;
     rv = aDir->IsDirectory(&isDir);
     if (NS_FAILED(rv)) return rv;
     NS_PRECONDITION(isDir, "not a directory");
     if (!isDir)
         return NS_ERROR_ILLEGAL_VALUE;
 
+#ifdef PR_LOGGING
     if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
         nsAutoCString path;
         aDir->GetNativePath(path);
         PR_LOG(gLog, PR_LOG_DEBUG,
                ("nsDirectoryIndexStream[%p]: initialized on %s",
                 this, path.get()));
     }
+#endif
 
     // Sigh. We have to allocate on the heap because there are no
     // assignment operators defined.
     nsCOMPtr<nsISimpleEnumerator> iter;
     rv = aDir->GetDirectoryEntries(getter_AddRefs(iter));
     if (NS_FAILED(rv)) return rv;
 
     // Now lets sort, because clients expect it that way
@@ -234,23 +240,25 @@ nsDirectoryIndexStream::Read(char* aBuf,
             bool more = mPos < mArray.Count();
             if (!more) break;
 
             // don't addref, for speed - an addref happened when it
             // was placed in the array, so it's not going to go stale
             nsIFile* current = mArray.ObjectAt(mPos);
             ++mPos;
 
+#ifdef PR_LOGGING
             if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
                 nsAutoCString path;
                 current->GetNativePath(path);
                 PR_LOG(gLog, PR_LOG_DEBUG,
                        ("nsDirectoryIndexStream[%p]: iterated %s",
                         this, path.get()));
             }
+#endif
 
             // rjc: don't return hidden files/directories!
             // bbaetz: why not?
             nsresult rv;
 #ifndef XP_UNIX
             bool hidden = false;
             current->IsHidden(&hidden);
             if (hidden) {
--- a/netwerk/base/nsInputStreamPump.cpp
+++ b/netwerk/base/nsInputStreamPump.cpp
@@ -16,20 +16,22 @@
 #include "GeckoProfiler.h"
 #include "nsIStreamListener.h"
 #include "nsILoadGroup.h"
 #include "nsNetCID.h"
 #include <algorithm>
 
 static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID);
 
+#if defined(PR_LOGGING)
 //
 // NSPR_LOG_MODULES=nsStreamPump:5
 //
 static PRLogModuleInfo *gStreamPumpLog = nullptr;
+#endif
 #undef LOG
 #define LOG(args) PR_LOG(gStreamPumpLog, PR_LOG_DEBUG, args)
 
 //-----------------------------------------------------------------------------
 // nsInputStreamPump methods
 //-----------------------------------------------------------------------------
 
 nsInputStreamPump::nsInputStreamPump()
@@ -40,18 +42,20 @@ nsInputStreamPump::nsInputStreamPump()
     , mSuspendCount(0)
     , mLoadFlags(LOAD_NORMAL)
     , mProcessingCallbacks(false)
     , mWaitingForInputStreamReady(false)
     , mCloseWhenDone(false)
     , mRetargeting(false)
     , mMonitor("nsInputStreamPump")
 {
+#if defined(PR_LOGGING)
     if (!gStreamPumpLog)
         gStreamPumpLog = PR_NewLogModule("nsStreamPump");
+#endif
 }
 
 nsInputStreamPump::~nsInputStreamPump()
 {
 }
 
 nsresult
 nsInputStreamPump::Create(nsInputStreamPump  **result,
--- a/netwerk/base/nsLoadGroup.cpp
+++ b/netwerk/base/nsLoadGroup.cpp
@@ -22,28 +22,30 @@
 #include "nsIInterfaceRequestor.h"
 #include "nsIRequestObserver.h"
 #include "CacheObserver.h"
 #include "MainThreadUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
+#if defined(PR_LOGGING)
 //
 // Log module for nsILoadGroup logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=LoadGroup:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables PR_LOG_DEBUG level information and places all output in
 // the file nspr.log
 //
 static PRLogModuleInfo* gLoadGroupLog = nullptr;
+#endif
 
 #undef LOG
 #define LOG(args) PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, args)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class RequestMapEntry : public PLDHashEntryHdr
 {
@@ -116,19 +118,21 @@ nsLoadGroup::nsLoadGroup(nsISupports* ou
     , mIsCanceling(false)
     , mDefaultLoadIsTimed(false)
     , mTimedRequests(0)
     , mCachedRequests(0)
     , mTimedNonCachedRequestsUntilOnEndPageLoad(0)
 {
     NS_INIT_AGGREGATED(outer);
 
+#if defined(PR_LOGGING)
     // Initialize the global PRLogModule for nsILoadGroup logging
     if (nullptr == gLoadGroupLog)
         gLoadGroupLog = PR_NewLogModule("LoadGroup");
+#endif
 
     LOG(("LOADGROUP [%x]: Created.\n", this));
 }
 
 nsLoadGroup::~nsLoadGroup()
 {
     DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED);
     NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
@@ -252,22 +256,22 @@ nsLoadGroup::Cancel(nsresult status)
         NS_ASSERTION(request, "NULL request found in list.");
 
         if (!PL_DHashTableSearch(&mRequests, request)) {
             // |request| was removed already
             NS_RELEASE(request);
             continue;
         }
 
-        if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) {
-            nsAutoCString nameStr;
-            request->GetName(nameStr);
-            LOG(("LOADGROUP [%x]: Canceling request %x %s.\n",
-                 this, request, nameStr.get()));
-        }
+#if defined(PR_LOGGING)
+        nsAutoCString nameStr;
+        request->GetName(nameStr);
+        LOG(("LOADGROUP [%x]: Canceling request %x %s.\n",
+             this, request, nameStr.get()));
+#endif
 
         //
         // Remove the request from the load group...  This may cause
         // the OnStopRequest notification to fire...
         //
         // XXX: What should the context be?
         //
         (void)RemoveRequest(request, nullptr, status);
@@ -320,22 +324,22 @@ nsLoadGroup::Suspend()
     //
     while (count > 0) {
         nsIRequest* request = requests.ElementAt(--count);
 
         NS_ASSERTION(request, "NULL request found in list.");
         if (!request)
             continue;
 
-        if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) {
-            nsAutoCString nameStr;
-            request->GetName(nameStr);
-            LOG(("LOADGROUP [%x]: Suspending request %x %s.\n",
-                this, request, nameStr.get()));
-        }
+#if defined(PR_LOGGING)
+        nsAutoCString nameStr;
+        request->GetName(nameStr);
+        LOG(("LOADGROUP [%x]: Suspending request %x %s.\n",
+            this, request, nameStr.get()));
+#endif
 
         // Suspend the request...
         rv = request->Suspend();
 
         // Remember the first failure and return it...
         if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
             firstError = rv;
 
@@ -372,22 +376,22 @@ nsLoadGroup::Resume()
     //
     while (count > 0) {
         nsIRequest* request = requests.ElementAt(--count);
 
         NS_ASSERTION(request, "NULL request found in list.");
         if (!request)
             continue;
 
-        if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) {
-            nsAutoCString nameStr;
-            request->GetName(nameStr);
-            LOG(("LOADGROUP [%x]: Resuming request %x %s.\n",
-                this, request, nameStr.get()));
-        }
+#if defined(PR_LOGGING)
+        nsAutoCString nameStr;
+        request->GetName(nameStr);
+        LOG(("LOADGROUP [%x]: Resuming request %x %s.\n",
+            this, request, nameStr.get()));
+#endif
 
         // Resume the request...
         rv = request->Resume();
 
         // Remember the first failure and return it...
         if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
             firstError = rv;
 
@@ -461,32 +465,37 @@ nsLoadGroup::SetDefaultLoadRequest(nsIRe
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
 {
     nsresult rv;
 
-    if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) {
+#if defined(PR_LOGGING)
+    {
         nsAutoCString nameStr;
         request->GetName(nameStr);
         LOG(("LOADGROUP [%x]: Adding request %x %s (count=%d).\n",
              this, request, nameStr.get(), mRequests.EntryCount()));
     }
+#endif /* PR_LOGGING */
 
     NS_ASSERTION(!PL_DHashTableSearch(&mRequests, request),
                  "Entry added to loadgroup twice, don't do that");
 
     //
     // Do not add the channel, if the loadgroup is being canceled...
     //
     if (mIsCanceling) {
+
+#if defined(PR_LOGGING)
         LOG(("LOADGROUP [%x]: AddChannel() ABORTED because LoadGroup is"
              " being canceled!!\n", this));
+#endif /* PR_LOGGING */
 
         return NS_BINDING_ABORTED;
     }
 
     nsLoadFlags flags;
     // if the request is the default load request or if the default
     // load request is null, then the load group should inherit its
     // load flags from the request.
@@ -558,22 +567,24 @@ nsLoadGroup::AddRequest(nsIRequest *requ
 
 NS_IMETHODIMP
 nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt,
                            nsresult aStatus)
 {
     NS_ENSURE_ARG_POINTER(request);
     nsresult rv;
 
-    if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) {
+#if defined(PR_LOGGING)
+    {
         nsAutoCString nameStr;
         request->GetName(nameStr);
         LOG(("LOADGROUP [%x]: Removing request %x %s status %x (count=%d).\n",
             this, request, nameStr.get(), aStatus, mRequests.EntryCount() - 1));
     }
+#endif
 
     // Make sure we have a owning reference to the request we're about
     // to remove.
 
     nsCOMPtr<nsIRequest> kungFuDeathGrip(request);
 
     //
     // Remove the request from the group.  If this fails, it means that
@@ -646,20 +657,22 @@ nsLoadGroup::RemoveRequest(nsIRequest *r
         // Fire the OnStopRequest out to the observer...
         nsCOMPtr<nsIRequestObserver> observer = do_QueryReferent(mObserver);
         if (observer) {
             LOG(("LOADGROUP [%x]: Firing OnStopRequest for request %x."
                  "(foreground count=%d).\n", this, request, mForegroundCount));
 
             rv = observer->OnStopRequest(request, ctxt, aStatus);
 
+#if defined(PR_LOGGING)
             if (NS_FAILED(rv)) {
                 LOG(("LOADGROUP [%x]: OnStopRequest for request %x FAILED.\n",
                     this, request));
             }
+#endif
         }
 
         // If that was the last request -> remove ourselves from loadgroup
         if (mForegroundCount == 0 && mLoadGroup) {
             mLoadGroup->RemoveRequest(this, nullptr, aStatus);
         }
     }
 
--- a/netwerk/base/nsPACMan.cpp
+++ b/netwerk/base/nsPACMan.cpp
@@ -20,16 +20,18 @@
 #ifdef MOZ_NUWA_PROCESS
 #include "ipc/Nuwa.h"
 #endif
 
 //-----------------------------------------------------------------------------
 using namespace mozilla;
 using namespace mozilla::net;
 
+#if defined(PR_LOGGING)
+#endif
 #undef LOG
 #define LOG(args) PR_LOG(GetProxyLog(), PR_LOG_DEBUG, args)
 
 // The PAC thread does evaluations of both PAC files and
 // nsISystemProxySettings because they can both block the calling thread and we
 // don't want that on the main thread
 
 // Check to see if the underlying request was not an error page in the case of
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -43,16 +43,18 @@ namespace mozilla {
   extern const char kProxyType_SOCKS4[];
   extern const char kProxyType_SOCKS5[];
   extern const char kProxyType_DIRECT[];
 }
 
 using namespace mozilla;
 
 #include "prlog.h"
+#if defined(PR_LOGGING)
+#endif
 #undef LOG
 #define LOG(args) PR_LOG(net::GetProxyLog(), PR_LOG_DEBUG, args)
 
 //----------------------------------------------------------------------------
 
 #define PROXY_PREF_BRANCH  "network.proxy"
 #define PROXY_PREF(x)      PROXY_PREF_BRANCH "." x
 
--- a/netwerk/base/nsRequestObserverProxy.cpp
+++ b/netwerk/base/nsRequestObserverProxy.cpp
@@ -8,17 +8,19 @@
 #include "nscore.h"
 #include "nsRequestObserverProxy.h"
 #include "nsIRequest.h"
 #include "nsAutoPtr.h"
 #include "prlog.h"
 
 using namespace mozilla;
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gRequestObserverProxyLog;
+#endif
 
 #undef LOG
 #define LOG(args) PR_LOG(gRequestObserverProxyLog, PR_LOG_DEBUG, args)
 
 //-----------------------------------------------------------------------------
 // nsARequestObserverEvent internal class...
 //-----------------------------------------------------------------------------
 
@@ -169,18 +171,20 @@ nsRequestObserverProxy::OnStopRequest(ns
 // nsRequestObserverProxy::nsIRequestObserverProxy implementation...
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsRequestObserverProxy::Init(nsIRequestObserver *observer, nsISupports *context)
 {
     NS_ENSURE_ARG_POINTER(observer);
 
+#if defined(PR_LOGGING)
     if (!gRequestObserverProxyLog)
         gRequestObserverProxyLog = PR_NewLogModule("nsRequestObserverProxy");
+#endif
 
     mObserver = new nsMainThreadPtrHolder<nsIRequestObserver>(observer);
     mContext = new nsMainThreadPtrHolder<nsISupports>(context);
 
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -1246,29 +1246,31 @@ nsSocketTransport::InitiateSocket()
             MOZ_CRASH("Attempting to connect to non-local address!");
         }
     }
 
     // Hosts/Proxy Hosts that are Local IP Literals should not be speculatively
     // connected - Bug 853423.
     if (mConnectionFlags & nsISocketTransport::DISABLE_RFC1918 &&
         IsIPAddrLocal(&mNetAddr)) {
+#ifdef PR_LOGGING
         if (SOCKET_LOG_ENABLED()) {
             nsAutoCString netAddrCString;
             netAddrCString.SetCapacity(kIPv6CStrBufSize);
             if (!NetAddrToString(&mNetAddr,
                                  netAddrCString.BeginWriting(),
                                  kIPv6CStrBufSize))
                 netAddrCString = NS_LITERAL_CSTRING("<IP-to-string failed>");
             SOCKET_LOG(("nsSocketTransport::InitiateSocket skipping "
                         "speculative connection for host [%s:%d] proxy "
                         "[%s:%d] with Local IP address [%s]",
                         mHost.get(), mPort, mProxyHost.get(), mProxyPort,
                         netAddrCString.get()));
         }
+#endif
         mCondition = NS_ERROR_CONNECTION_REFUSED;
         OnSocketDetached(nullptr);
         return mCondition;
     }
 
     //
     // find out if it is going to be ok to attach another socket to the STS.
     // if not then we have to wait for the STS to tell us that it is ok.
@@ -1365,21 +1367,23 @@ nsSocketTransport::InitiateSocket()
         mFDconnected = false;
     }
 
     SOCKET_LOG(("  advancing to STATE_CONNECTING\n"));
     mState = STATE_CONNECTING;
     mPollTimeout = mTimeouts[TIMEOUT_CONNECT];
     SendStatus(NS_NET_STATUS_CONNECTING_TO);
 
+#if defined(PR_LOGGING)
     if (SOCKET_LOG_ENABLED()) {
         char buf[kNetAddrMaxCStrBufSize];
         NetAddrToString(&mNetAddr, buf, sizeof(buf));
         SOCKET_LOG(("  trying address: %s\n", buf));
     }
+#endif
 
     //
     // Initiate the connect() to the host...
     //
     PRNetAddr prAddr;
     {
         if (mBindAddr) {
             MutexAutoLock lock(mLock);
@@ -2798,17 +2802,17 @@ nsSocketTransport::TraceOutBuf(const cha
 
     DumpBytesToFile(val, header.get(), buf, n);
 }
 
 #endif
 
 static void LogNSPRError(const char* aPrefix, const void *aObjPtr)
 {
-#if defined(DEBUG)
+#if defined(PR_LOGGING) && defined(DEBUG)
     PRErrorCode errCode = PR_GetError();
     int errLen = PR_GetErrorTextLength();
     nsAutoCString errStr;
     if (errLen > 0) {
         errStr.SetLength(errLen);
         PR_GetErrorText(errStr.BeginWriting());
     }
     NS_WARNING(nsPrintfCString(
@@ -2838,17 +2842,17 @@ nsSocketTransport::PRFileDescAutoLock::S
                      mSocketTransport);
         return ErrorAccordingToNSPR(PR_GetError());
     }
     return NS_OK;
 }
 
 static void LogOSError(const char *aPrefix, const void *aObjPtr)
 {
-#if defined(DEBUG)
+#if defined(PR_LOGGING) && defined(DEBUG)
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
 #ifdef XP_WIN
     DWORD errCode = WSAGetLastError();
     LPVOID errMessage;
     FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                   FORMAT_MESSAGE_FROM_SYSTEM |
                   FORMAT_MESSAGE_IGNORE_INSERTS,
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -24,17 +24,19 @@
 #include "mozilla/PodOperations.h"
 #include "mozilla/Telemetry.h"
 #include "nsThreadUtils.h"
 #include "nsIFile.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo *gSocketTransportLog = nullptr;
+#endif
 
 nsSocketTransportService *gSocketTransportService = nullptr;
 PRThread                 *gSocketThread           = nullptr;
 
 #define SEND_BUFFER_PREF "network.tcp.sendbuffer"
 #define KEEPALIVE_ENABLED_PREF "network.tcp.keepalive.enabled"
 #define KEEPALIVE_IDLE_TIME_PREF "network.tcp.keepalive.idle_time"
 #define KEEPALIVE_RETRY_INTERVAL_PREF "network.tcp.keepalive.retry_interval"
@@ -73,17 +75,19 @@ nsSocketTransportService::nsSocketTransp
     , mKeepaliveProbeCount(kDefaultTCPKeepCount)
     , mKeepaliveEnabledPref(false)
     , mServeMultipleEventsPerPollIter(true)
     , mServingPendingQueue(false)
     , mMaxTimePerPollIter(100)
     , mTelemetryEnabledPref(false)
     , mProbedMaxCount(false)
 {
+#if defined(PR_LOGGING)
     gSocketTransportLog = PR_NewLogModule("nsSocketTransport");
+#endif
 
     NS_ASSERTION(NS_IsMainThread(), "wrong thread");
 
     PR_CallOnce(&gMaxCountInitOnce, DiscoverMaxCount);
     mActiveList = (SocketContext *)
         moz_xmalloc(sizeof(SocketContext) * mActiveListSize);
     mIdleList = (SocketContext *)
         moz_xmalloc(sizeof(SocketContext) * mIdleListSize);
--- a/netwerk/base/nsSocketTransportService2.h
+++ b/netwerk/base/nsSocketTransportService2.h
@@ -20,20 +20,22 @@
 #include "mozilla/Atomics.h"
 #include "mozilla/TimeStamp.h"
 
 class nsASocketHandler;
 struct PRPollDesc;
 
 //-----------------------------------------------------------------------------
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=nsSocketTransport:5
 //
 extern PRLogModuleInfo *gSocketTransportLog;
+#endif
 #define SOCKET_LOG(args)     PR_LOG(gSocketTransportLog, PR_LOG_DEBUG, args)
 #define SOCKET_LOG_ENABLED() PR_LOG_TEST(gSocketTransportLog, PR_LOG_DEBUG)
 
 //-----------------------------------------------------------------------------
 
 #define NS_SOCKET_POLL_TIMEOUT PR_INTERVAL_NO_TIMEOUT
 
 //-----------------------------------------------------------------------------
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -32,20 +32,22 @@ static NS_DEFINE_CID(kThisImplCID, NS_TH
 static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
 
 nsIIDNService *nsStandardURL::gIDN = nullptr;
 bool nsStandardURL::gInitialized = false;
 bool nsStandardURL::gEscapeUTF8 = true;
 bool nsStandardURL::gAlwaysEncodeInUTF8 = true;
 char nsStandardURL::gHostLimitDigits[] = { '/', '\\', '?', '#', 0 };
 
+#if defined(PR_LOGGING)
 //
 // setenv NSPR_LOG_MODULES nsStandardURL:5
 //
 static PRLogModuleInfo *gStandardURLLog;
+#endif
 
 // The Chromium code defines its own LOG macro which we don't want
 #undef LOG
 #define LOG(args)     PR_LOG(gStandardURLLog, PR_LOG_DEBUG, args)
 #undef LOG_ENABLED
 #define LOG_ENABLED() PR_LOG_TEST(gStandardURLLog, PR_LOG_DEBUG)
 
 //----------------------------------------------------------------------------
@@ -247,18 +249,20 @@ nsStandardURL::nsStandardURL(bool aSuppo
     , mPort(-1)
     , mHostA(nullptr)
     , mHostEncoding(eEncoding_ASCII)
     , mSpecEncoding(eEncoding_Unknown)
     , mURLType(URLTYPE_STANDARD)
     , mMutable(true)
     , mSupportsFileURL(aSupportsFileURL)
 {
+#if defined(PR_LOGGING)
     if (!gStandardURLLog)
         gStandardURLLog = PR_NewLogModule("nsStandardURL");
+#endif
 
     LOG(("Creating nsStandardURL @%p\n", this));
 
     if (!gInitialized) {
         gInitialized = true;
         InitGlobalObjects();
     }
 
@@ -1197,32 +1201,34 @@ nsStandardURL::SetSpec(const nsACString 
     if (NS_FAILED(rv)) {
         Clear();
         // If parsing the spec has failed, restore the old URL
         // so we don't end up with an empty URL.
         CopyMembers(&prevURL, eHonorRef);
         return rv;
     }
 
+#if defined(PR_LOGGING)
     if (LOG_ENABLED()) {
         LOG((" spec      = %s\n", mSpec.get()));
         LOG((" port      = %d\n", mPort));
         LOG((" scheme    = (%u,%d)\n", mScheme.mPos,    mScheme.mLen));
         LOG((" authority = (%u,%d)\n", mAuthority.mPos, mAuthority.mLen));
         LOG((" username  = (%u,%d)\n", mUsername.mPos,  mUsername.mLen));
         LOG((" password  = (%u,%d)\n", mPassword.mPos,  mPassword.mLen));
         LOG((" hostname  = (%u,%d)\n", mHost.mPos,      mHost.mLen));
         LOG((" path      = (%u,%d)\n", mPath.mPos,      mPath.mLen));
         LOG((" filepath  = (%u,%d)\n", mFilepath.mPos,  mFilepath.mLen));
         LOG((" directory = (%u,%d)\n", mDirectory.mPos, mDirectory.mLen));
         LOG((" basename  = (%u,%d)\n", mBasename.mPos,  mBasename.mLen));
         LOG((" extension = (%u,%d)\n", mExtension.mPos, mExtension.mLen));
         LOG((" query     = (%u,%d)\n", mQuery.mPos,     mQuery.mLen));
         LOG((" ref       = (%u,%d)\n", mRef.mPos,       mRef.mLen));
     }
+#endif
     return rv;
 }
 
 NS_IMETHODIMP
 nsStandardURL::SetScheme(const nsACString &input)
 {
     ENSURE_MUTABLE();
 
@@ -2699,22 +2705,24 @@ NS_IMETHODIMP
 nsStandardURL::GetFile(nsIFile **result)
 {
     NS_PRECONDITION(mSupportsFileURL,
                     "GetFile() called on a URL that doesn't support files!");
     nsresult rv = EnsureFile();
     if (NS_FAILED(rv))
         return rv;
 
+#if defined(PR_LOGGING)
     if (LOG_ENABLED()) {
         nsAutoCString path;
         mFile->GetNativePath(path);
         LOG(("nsStandardURL::GetFile [this=%p spec=%s resulting_path=%s]\n",
             this, mSpec.get(), path.get()));
     }
+#endif
 
     // clone the file, so the caller can modify it.
     // XXX nsIFileURL.idl specifies that the consumer must _not_ modify the
     // nsIFile returned from this method; but it seems that some folks do
     // (see bug 161921). until we can be sure that all the consumers are
     // behaving themselves, we'll stay on the safe side and clone the file.
     // see bug 212724 about fixing the consumers.
     return mFile->Clone(result);
--- a/netwerk/cache/nsCache.cpp
+++ b/netwerk/cache/nsCache.cpp
@@ -9,16 +9,17 @@
 #include "nsDependentSubstring.h"
 #include "nsString.h"
 
 
 /**
  * Cache Service Utility Functions
  */
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo * gCacheLog = nullptr;
 
 
 void
 CacheLogInit()
 {
     if (gCacheLog) return;
     gCacheLog = PR_NewLogModule("cache");
@@ -33,16 +34,18 @@ CacheLogPrintPath(PRLogModuleLevel level
     nsresult rv = item->GetNativePath(path);
     if (NS_SUCCEEDED(rv)) {
         PR_LOG(gCacheLog, level, (format, path.get()));
     } else {
         PR_LOG(gCacheLog, level, ("GetNativePath failed: %x", rv));
     }
 }
 
+#endif
+
 
 uint32_t
 SecondsFromPRTime(PRTime prTime)
 {
   int64_t  microSecondsPerSecond = PR_USEC_PER_SEC;
   return uint32_t(prTime / microSecondsPerSecond);
 }
 
--- a/netwerk/cache/nsCache.h
+++ b/netwerk/cache/nsCache.h
@@ -14,28 +14,37 @@
 #include "prlog.h"
 #include "nsISupports.h"
 #include "nsIFile.h"
 #include "nsAString.h"
 #include "prtime.h"
 #include "nsError.h"
 
 // PR_LOG args = "format string", arg, arg, ...
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo * gCacheLog;
 void   CacheLogInit();
 void   CacheLogPrintPath(PRLogModuleLevel level,
                          const char *     format,
                          nsIFile *        item);
 #define CACHE_LOG_INIT()        CacheLogInit()
 #define CACHE_LOG_ALWAYS(args)  PR_LOG(gCacheLog, PR_LOG_ALWAYS, args)
 #define CACHE_LOG_ERROR(args)   PR_LOG(gCacheLog, PR_LOG_ERROR, args)
 #define CACHE_LOG_WARNING(args) PR_LOG(gCacheLog, PR_LOG_WARNING, args)
 #define CACHE_LOG_DEBUG(args)   PR_LOG(gCacheLog, PR_LOG_DEBUG, args)
 #define CACHE_LOG_PATH(level, format, item) \
                                 CacheLogPrintPath(level, format, item)
+#else
+#define CACHE_LOG_INIT()        {}
+#define CACHE_LOG_ALWAYS(args)  {}
+#define CACHE_LOG_ERROR(args)   {}
+#define CACHE_LOG_WARNING(args) {}
+#define CACHE_LOG_DEBUG(args)   {}
+#define CACHE_LOG_PATH(level, format, item)  {}
+#endif
 
 
 extern uint32_t  SecondsFromPRTime(PRTime prTime);
 extern PRTime    PRTimeFromSeconds(uint32_t seconds);
 
 
 extern nsresult  ClientIDFromCacheKey(const nsACString&  key, char ** result);
 extern nsresult  ClientKeyFromCacheKey(const nsCString& key, nsACString &result);
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -291,17 +291,19 @@ private:
 class nsBlockOnCacheThreadEvent : public nsRunnable {
 public:
     nsBlockOnCacheThreadEvent()
     {
     }
     NS_IMETHOD Run()
     {
         nsCacheServiceAutoLock autoLock(LOCK_TELEM(NSBLOCKONCACHETHREADEVENT_RUN));
+#ifdef PR_LOGGING
         CACHE_LOG_DEBUG(("nsBlockOnCacheThreadEvent [%p]\n", this));
+#endif
         nsCacheService::gService->mCondVar.Notify();
         return NS_OK;
     }
 };
 
 
 nsresult
 nsCacheProfilePrefObserver::Install()
@@ -1245,17 +1247,19 @@ nsCacheService::Shutdown()
 
         if (mOfflineDevice)
             mOfflineDevice->Shutdown();
 
         NS_IF_RELEASE(mOfflineDevice);
 
         mCustomOfflineDevices.Enumerate(&nsCacheService::ShutdownCustomCacheDeviceEnum, nullptr);
 
+#ifdef PR_LOGGING
         LogCacheStatistics();
+#endif
 
         mClearingEntries = false;
         mCacheIOThread.swap(cacheIOThread);
     }
 
     if (cacheIOThread)
         nsShutdownThread::BlockingShutdown(cacheIOThread);
 
@@ -1762,22 +1766,22 @@ nsCacheService::CreateOfflineDevice()
 
 nsresult
 nsCacheService::CreateCustomOfflineDevice(nsIFile *aProfileDir,
                                           int32_t aQuota,
                                           nsOfflineCacheDevice **aDevice)
 {
     NS_ENSURE_ARG(aProfileDir);
 
-    if (PR_LOG_TEST(gCacheLog, PR_LOG_ALWAYS)) {
-      nsAutoCString profilePath;
-      aProfileDir->GetNativePath(profilePath);
-      CACHE_LOG_ALWAYS(("Creating custom offline device, %s, %d",
-                        profilePath.BeginReading(), aQuota));
-    }
+#if defined(PR_LOGGING)
+    nsAutoCString profilePath;
+    aProfileDir->GetNativePath(profilePath);
+    CACHE_LOG_ALWAYS(("Creating custom offline device, %s, %d",
+                      profilePath.BeginReading(), aQuota));
+#endif
 
     if (!mInitialized)         return NS_ERROR_NOT_AVAILABLE;
     if (!mEnableOfflineDevice) return NS_ERROR_NOT_AVAILABLE;
 
     *aDevice = new nsOfflineCacheDevice;
 
     NS_ADDREF(*aDevice);
 
@@ -3108,16 +3112,17 @@ void nsCacheService::GetAppCacheDirector
     nsresult rv = directory->AppendNative(NS_LITERAL_CSTRING("OfflineCache"));
     if (NS_FAILED(rv))
         return;
 
     directory.forget(result);
 }
 
 
+#if defined(PR_LOGGING)
 void
 nsCacheService::LogCacheStatistics()
 {
     uint32_t hitPercentage = (uint32_t)((((double)mCacheHits) /
         ((double)(mCacheHits + mCacheMisses))) * 100);
     CACHE_LOG_ALWAYS(("\nCache Service Statistics:\n\n"));
     CACHE_LOG_ALWAYS(("    TotalEntries   = %d\n", mTotalEntries));
     CACHE_LOG_ALWAYS(("    Cache Hits     = %d\n", mCacheHits));
@@ -3127,16 +3132,17 @@ nsCacheService::LogCacheStatistics()
     CACHE_LOG_ALWAYS(("    Max Meta Size  = %d\n", mMaxMetaSize));
     CACHE_LOG_ALWAYS(("    Max Data Size  = %d\n", mMaxDataSize));
     CACHE_LOG_ALWAYS(("\n"));
     CACHE_LOG_ALWAYS(("    Deactivate Failures         = %d\n",
                       mDeactivateFailures));
     CACHE_LOG_ALWAYS(("    Deactivated Unbound Entries = %d\n",
                       mDeactivatedUnboundEntries));
 }
+#endif
 
 nsresult
 nsCacheService::SetDiskSmartSize()
 {
     nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETDISKSMARTSIZE));
 
     if (!gService) return NS_ERROR_NOT_AVAILABLE;
 
--- a/netwerk/cache/nsCacheService.h
+++ b/netwerk/cache/nsCacheService.h
@@ -320,17 +320,19 @@ private:
                                        PLDHashEntryHdr * hdr,
                                        uint32_t          number,
                                        void *            arg);
 
     static
     PLDHashOperator  ShutdownCustomCacheDeviceEnum(const nsAString& aProfileDir,
                                                    nsRefPtr<nsOfflineCacheDevice>& aDevice,
                                                    void* aUserArg);
+#if defined(PR_LOGGING)
     void LogCacheStatistics();
+#endif
 
     nsresult         SetDiskSmartSize_Locked();
 
     /**
      *  Data Members
      */
 
     static nsCacheService *         gService;  // there can be only one...
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -60,17 +60,19 @@ public:
           mDevice(device),
           mBinding(binding)
     {
     }
 
     NS_IMETHOD Run()
     {
         nsCacheServiceAutoLock lock(LOCK_TELEM(NSDISKCACHEDEVICEDEACTIVATEENTRYEVENT_RUN));
+#ifdef PR_LOGGING
         CACHE_LOG_DEBUG(("nsDiskCacheDeviceDeactivateEntryEvent[%p]\n", this));
+#endif
         if (!mCanceled) {
             (void) mDevice->DeactivateEntry_Private(mEntry, mBinding);
         }
         return NS_OK;
     }
 
     void CancelEvent() { mCanceled = true; }
 private:
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -220,21 +220,21 @@ nsOfflineCacheEvictionFunction::OnFuncti
 }
 
 void
 nsOfflineCacheEvictionFunction::Apply()
 {
   LOG(("nsOfflineCacheEvictionFunction::Apply\n"));
 
   for (int32_t i = 0; i < mItems.Count(); i++) {
-    if (PR_LOG_TEST(gCacheLog, PR_LOG_DEBUG)) {
-      nsAutoCString path;
-      mItems[i]->GetNativePath(path);
-      LOG(("  removing %s\n", path.get()));
-    }
+#if defined(PR_LOGGING)
+    nsAutoCString path;
+    mItems[i]->GetNativePath(path);
+    LOG(("  removing %s\n", path.get()));
+#endif
 
     mItems[i]->Remove(false);
   }
 
   Reset();
 }
 
 class nsOfflineCacheDiscardCache : public nsRunnable
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -1872,17 +1872,20 @@ CacheFile::FailListenersIfNonExistentChu
 }
 
 PLDHashOperator
 CacheFile::FailUpdateListeners(
   const uint32_t& aIdx,
   nsRefPtr<CacheFileChunk>& aChunk,
   void* aClosure)
 {
+#ifdef PR_LOGGING
   CacheFile *file = static_cast<CacheFile*>(aClosure);
+#endif
+
   LOG(("CacheFile::FailUpdateListeners() [this=%p, idx=%u]",
        file, aIdx));
 
   if (aChunk->IsReady()) {
     aChunk->NotifyUpdateListeners();
   }
 
   return PL_DHASH_NEXT;
--- a/netwerk/cache2/CacheFileContextEvictor.cpp
+++ b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -241,18 +241,20 @@ CacheFileContextEvictor::PersistEviction
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   nsCOMPtr<nsIFile> file;
   rv = GetContextFile(aLoadContextInfo, getter_AddRefs(file));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
+#ifdef PR_LOGGING
   nsAutoCString path;
   file->GetNativePath(path);
+#endif
 
   PRFileDesc *fd;
   rv = file->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 0600,
                               &fd);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("CacheFileContextEvictor::PersistEvictionInfoToDisk() - Creating file "
          "failed! [path=%s, rv=0x%08x]", path.get(), rv));
     return rv;
@@ -278,18 +280,20 @@ CacheFileContextEvictor::RemoveEvictInfo
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   nsCOMPtr<nsIFile> file;
   rv = GetContextFile(aLoadContextInfo, getter_AddRefs(file));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
+#ifdef PR_LOGGING
   nsAutoCString path;
   file->GetNativePath(path);
+#endif
 
   rv = file->Remove(false);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("CacheFileContextEvictor::RemoveEvictionInfoFromDisk() - Removing file"
          " failed! [path=%s, rv=0x%08x]", path.get(), rv));
     return rv;
   }
 
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -2963,18 +2963,20 @@ CacheFileIOManager::CacheIndexStateChang
 
   mContextEvictor->CacheIndexStateChanged();
   return NS_OK;
 }
 
 nsresult
 CacheFileIOManager::TrashDirectory(nsIFile *aFile)
 {
+#ifdef PR_LOGGING
   nsAutoCString path;
   aFile->GetNativePath(path);
+#endif
   LOG(("CacheFileIOManager::TrashDirectory() [file=%s]", path.get()));
 
   nsresult rv;
 
   MOZ_ASSERT(mIOThread->IsCurrentThread());
   MOZ_ASSERT(mCacheDirectory);
 
   // When the directory is empty, it is cheaper to remove it directly instead of
@@ -3194,23 +3196,23 @@ CacheFileIOManager::RemoveTrashInternal(
       mTrashDirEnumerator = nullptr;
       continue; // check elapsed time
     } else {
       bool isDir = false;
       file->IsDirectory(&isDir);
       if (isDir) {
         NS_WARNING("Found a directory in a trash directory! It will be removed "
                    "recursively, but this can block IO thread for a while!");
-        if (LOG_ENABLED()) {
-          nsAutoCString path;
-          file->GetNativePath(path);
-          LOG(("CacheFileIOManager::RemoveTrashInternal() - Found a directory in a trash "
-              "directory! It will be removed recursively, but this can block IO "
-              "thread for a while! [file=%s]", path.get()));
-        }
+#ifdef PR_LOGGING
+        nsAutoCString path;
+        file->GetNativePath(path);
+#endif
+        LOG(("CacheFileIOManager::RemoveTrashInternal() - Found a directory in a trash "
+            "directory! It will be removed recursively, but this can block IO "
+            "thread for a while! [file=%s]", path.get()));
       }
       file->Remove(isDir);
     }
   }
 
   NS_NOTREACHED("We should never get here");
   return NS_OK;
 }
@@ -3754,22 +3756,23 @@ CacheFileIOManager::SyncRemoveDir(nsIFil
     }
 
     rv = file->AppendNative(nsDependentCString(aDir));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
-  if (LOG_ENABLED()) {
-    nsAutoCString path;
-    file->GetNativePath(path);
-    LOG(("CacheFileIOManager::SyncRemoveDir() - Removing directory %s",
-         path.get()));
-  }
+#ifdef PR_LOGGING
+  nsAutoCString path;
+  file->GetNativePath(path);
+#endif
+
+  LOG(("CacheFileIOManager::SyncRemoveDir() - Removing directory %s",
+       path.get()));
 
   rv = file->Remove(true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     LOG(("CacheFileIOManager::SyncRemoveDir() - Removing failed! [rv=0x%08x]",
          rv));
   }
 
   return rv;
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -3077,16 +3077,17 @@ CacheIndex::RemoveNonFreshEntries(CacheI
   CacheIndex *index = static_cast<CacheIndex *>(aClosure);
 
   CacheIndexEntryAutoManage emng(aEntry->Hash(), index);
   emng.DoNotSearchInIndex();
 
   return PL_DHASH_REMOVE;
 }
 
+#ifdef PR_LOGGING
 // static
 char const *
 CacheIndex::StateString(EState aState)
 {
   switch (aState) {
     case INITIAL:  return "INITIAL";
     case READING:  return "READING";
     case WRITING:  return "WRITING";
@@ -3094,16 +3095,17 @@ CacheIndex::StateString(EState aState)
     case UPDATING: return "UPDATING";
     case READY:    return "READY";
     case SHUTDOWN: return "SHUTDOWN";
   }
 
   MOZ_ASSERT(false, "Unexpected state!");
   return "?";
 }
+#endif
 
 void
 CacheIndex::ChangeState(EState aNewState)
 {
   LOG(("CacheIndex::ChangeState() changing state %s -> %s", StateString(mState),
        StateString(aNewState)));
 
   // All pending updates should be processed before changing state
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -901,17 +901,19 @@ private:
     //  -> UPDATING - Index was found outdated.
     //  -> SHUTDOWN - Index is shutting down.
     READY    = 5,
 
     // Index is shutting down.
     SHUTDOWN = 6
   };
 
+#ifdef PR_LOGGING
   static char const * StateString(EState aState);
+#endif
   void ChangeState(EState aNewState);
 
   // Allocates and releases buffer used for reading and writing index.
   void AllocBuffer();
   void ReleaseBuffer();
 
   // Methods used by CacheIndexEntryAutoManage to keep the arrays up to date.
   void InsertRecordToFrecencyArray(CacheIndexRecord *aRecord);
--- a/netwerk/cache2/CacheLog.cpp
+++ b/netwerk/cache2/CacheLog.cpp
@@ -2,27 +2,29 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CacheLog.h"
 
 namespace mozilla {
 namespace net {
 
+#if defined(PR_LOGGING)
 // Log module for cache2 (2013) cache implementation logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=cache2:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables PR_LOG_DEBUG level information and places all output in
 // the file nspr.log
 PRLogModuleInfo* GetCache2Log()
 {
   static PRLogModuleInfo *sLog;
   if (!sLog)
     sLog = PR_NewLogModule("cache2");
   return sLog;
 }
+#endif
 
 } // net
 } // mozilla
--- a/netwerk/cache2/CacheLog.h
+++ b/netwerk/cache2/CacheLog.h
@@ -5,16 +5,19 @@
 #ifndef Cache2Log__h__
 #define Cache2Log__h__
 
 #include "prlog.h"
 
 namespace mozilla {
 namespace net {
 
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo* GetCache2Log();
 #define LOG(x)  PR_LOG(GetCache2Log(), PR_LOG_DEBUG, x)
-#define LOG_ENABLED() PR_LOG_TEST(GetCache2Log(), PR_LOG_DEBUG)
+#else
+#define LOG(x)
+#endif /* PR_LOGGING */
 
 } // net
 } // mozilla
 
 #endif
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -1201,17 +1201,19 @@ CacheStorageService::PurgeOverMemoryLimi
 
   Pool(true).PurgeOverMemoryLimit();
   Pool(false).PurgeOverMemoryLimit();
 }
 
 void
 CacheStorageService::MemoryPool::PurgeOverMemoryLimit()
 {
+#ifdef PR_LOGGING
   TimeStamp start(TimeStamp::Now());
+#endif
 
   uint32_t const memoryLimit = Limit();
   if (mMemorySize > memoryLimit) {
     LOG(("  memory data consumption over the limit, abandon expired entries"));
     PurgeExpired();
   }
 
   bool frecencyNeedsSort = true;
@@ -1437,22 +1439,22 @@ CacheStorageService::CheckStorageEntry(C
 
   nsAutoCString contextKey;
   CacheFileUtils::AppendKeyPrefix(aStorage->LoadInfo(), contextKey);
 
   if (!aStorage->WriteToDisk()) {
     AppendMemoryStorageID(contextKey);
   }
 
-  if (LOG_ENABLED()) {
-    nsAutoCString uriSpec;
-    aURI->GetAsciiSpec(uriSpec);
-    LOG(("CacheStorageService::CheckStorageEntry [uri=%s, eid=%s, contextKey=%s]",
-      uriSpec.get(), aIdExtension.BeginReading(), contextKey.get()));
-  }
+#ifdef PR_LOGGING
+  nsAutoCString uriSpec;
+  aURI->GetAsciiSpec(uriSpec);
+  LOG(("CacheStorageService::CheckStorageEntry [uri=%s, eid=%s, contextKey=%s]",
+    uriSpec.get(), aIdExtension.BeginReading(), contextKey.get()));
+#endif
 
   {
     mozilla::MutexAutoLock lock(mLock);
 
     NS_ENSURE_FALSE(mShutdown, NS_ERROR_NOT_INITIALIZED);
 
     nsAutoCString entryKey;
     rv = CacheEntry::HashingKey(EmptyCString(), aIdExtension, aURI, entryKey);
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -185,16 +185,17 @@ struct nsListIter
 //
 #include "prlog.h"
 #endif
 
 // define logging macros for convenience
 #define SET_COOKIE true
 #define GET_COOKIE false
 
+#ifdef PR_LOGGING
 static PRLogModuleInfo *
 GetCookieLog()
 {
   static PRLogModuleInfo *sCookieLog;
   if (!sCookieLog)
     sCookieLog = PR_NewLogModule("cookie");
   return sCookieLog;
 }
@@ -316,16 +317,23 @@ LogFailure(bool aSetCookie, nsIURI *aHos
 }
 
 static inline void
 LogSuccess(bool aSetCookie, nsIURI *aHostURI, const nsAFlatCString &aCookieString, nsCookie *aCookie, bool aReplacing)
 {
   LogSuccess(aSetCookie, aHostURI, aCookieString.get(), aCookie, aReplacing);
 }
 
+#else
+#define COOKIE_LOGFAILURE(a, b, c, d)    PR_BEGIN_MACRO /* nothing */ PR_END_MACRO
+#define COOKIE_LOGSUCCESS(a, b, c, d, e) PR_BEGIN_MACRO /* nothing */ PR_END_MACRO
+#define COOKIE_LOGEVICTED(a, b)          PR_BEGIN_MACRO /* nothing */ PR_END_MACRO
+#define COOKIE_LOGSTRING(a, b)           PR_BEGIN_MACRO /* nothing */ PR_END_MACRO
+#endif
+
 #ifdef DEBUG
 #define NS_ASSERT_SUCCESS(res)                                               \
   PR_BEGIN_MACRO                                                             \
   nsresult __rv = res; /* Do not evaluate |res| more than once! */           \
   if (NS_FAILED(__rv)) {                                                     \
     char *msg = PR_smprintf("NS_ASSERT_SUCCESS(%s) failed with result 0x%X", \
                             #res, __rv);                                     \
     NS_ASSERTION(NS_SUCCEEDED(__rv), msg);                                   \
@@ -346,27 +354,27 @@ class DBListenerErrorHandler : public mo
 protected:
   explicit DBListenerErrorHandler(DBState* dbState) : mDBState(dbState) { }
   nsRefPtr<DBState> mDBState;
   virtual const char *GetOpType() = 0;
 
 public:
   NS_IMETHOD HandleError(mozIStorageError* aError) override
   {
-    if (PR_LOG_TEST(GetCookieLog(), PR_LOG_WARNING)) {
-      int32_t result = -1;
-      aError->GetResult(&result);
-
-      nsAutoCString message;
-      aError->GetMessage(message);
-      COOKIE_LOGSTRING(PR_LOG_WARNING,
-        ("DBListenerErrorHandler::HandleError(): Error %d occurred while "
-         "performing operation '%s' with message '%s'; rebuilding database.",
-         result, GetOpType(), message.get()));
-    }
+    int32_t result = -1;
+    aError->GetResult(&result);
+
+#ifdef PR_LOGGING
+    nsAutoCString message;
+    aError->GetMessage(message);
+    COOKIE_LOGSTRING(PR_LOG_WARNING,
+      ("DBListenerErrorHandler::HandleError(): Error %d occurred while "
+       "performing operation '%s' with message '%s'; rebuilding database.",
+       result, GetOpType(), message.get()));
+#endif
 
     // Rebuild the database.
     gCookieService->HandleCorruptDB(mDBState);
 
     return NS_OK;
   }
 };
 
@@ -3765,20 +3773,22 @@ purgeCookiesCallback(nsCookieEntry *aEnt
 
 // purges expired and old cookies in a batch operation.
 already_AddRefed<nsIArray>
 nsCookieService::PurgeCookies(int64_t aCurrentTimeInUsec)
 {
   NS_ASSERTION(mDBState->hostTable.Count() > 0, "table is empty");
   EnsureReadComplete();
 
+#ifdef PR_LOGGING
   uint32_t initialCookieCount = mDBState->cookieCount;
   COOKIE_LOGSTRING(PR_LOG_DEBUG,
     ("PurgeCookies(): beginning purge with %ld cookies and %lld oldest age",
      mDBState->cookieCount, aCurrentTimeInUsec - mDBState->cookieOldestTime));
+#endif
 
   nsAutoTArray<nsListIter, kMaxNumberOfCookies> purgeList;
 
   nsCOMPtr<nsIMutableArray> removedList = do_CreateInstance(NS_ARRAY_CONTRACTID);
 
   // Create a params array to batch the removals. This is OK here because
   // all the removals are in order, and there are no interleaved additions.
   mozIStorageAsyncStatement *stmt = mDBState->stmtDelete;
@@ -3786,17 +3796,19 @@ nsCookieService::PurgeCookies(int64_t aC
   if (mDBState->dbConn) {
     stmt->NewBindingParamsArray(getter_AddRefs(paramsArray));
   }
 
   nsPurgeData data(aCurrentTimeInUsec / PR_USEC_PER_SEC,
     aCurrentTimeInUsec - mCookiePurgeAge, purgeList, removedList, paramsArray);
   mDBState->hostTable.EnumerateEntries(purgeCookiesCallback, &data);
 
+#ifdef PR_LOGGING
   uint32_t postExpiryCookieCount = mDBState->cookieCount;
+#endif
 
   // now we have a list of iterators for cookies over the age limit.
   // sort them by age, and then we'll see how many to remove...
   purgeList.Sort(CompareCookiesByAge());
 
   // only remove old cookies until we reach the max cookie limit, no more.
   uint32_t excess = mDBState->cookieCount > mMaxNumberOfCookies ?
     mDBState->cookieCount - mMaxNumberOfCookies : 0;
--- a/netwerk/dns/GetAddrInfo.cpp
+++ b/netwerk/dns/GetAddrInfo.cpp
@@ -18,21 +18,26 @@
 #include <algorithm>
 #include "prerror.h"
 
 #if defined(ANDROID) && ANDROID_VERSION > 19
 #include <resolv_netid.h>
 #endif
 
 #include "prlog.h"
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gGetAddrInfoLog = PR_NewLogModule("GetAddrInfo");
 #define LOG(msg, ...) \
   PR_LOG(gGetAddrInfoLog, PR_LOG_DEBUG, ("[DNS]: " msg, ##__VA_ARGS__))
 #define LOG_WARNING(msg, ...) \
   PR_LOG(gGetAddrInfoLog, PR_LOG_WARNING, ("[DNS]: " msg, ##__VA_ARGS__))
+#else
+#define LOG(args)
+#define LOG_WARNING(args)
+#endif
 
 #if DNSQUERY_AVAILABLE
 // There is a bug in windns.h where the type of parameter ppQueryResultsSet for
 // DnsQuery_A is dependent on UNICODE being set. It should *always* be
 // PDNS_RECORDA, but if UNICODE is set it is PDNS_RECORDW. To get around this
 // we make sure that UNICODE is unset.
 #undef UNICODE
 #include <ws2tcpip.h>
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -64,18 +64,22 @@ static const unsigned int NEGATIVE_RECOR
 #define HighThreadThreshold     MAX_RESOLVER_THREADS_FOR_ANY_PRIORITY
 #define LongIdleTimeoutSeconds  300           // for threads 1 -> HighThreadThreshold
 #define ShortIdleTimeoutSeconds 60            // for threads HighThreadThreshold+1 -> MAX_RESOLVER_THREADS
 
 PR_STATIC_ASSERT (HighThreadThreshold <= MAX_RESOLVER_THREADS);
 
 //----------------------------------------------------------------------------
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gHostResolverLog = nullptr;
 #define LOG(args) PR_LOG(gHostResolverLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 #define LOG_HOST(host, interface) host,                                        \
                  (interface && interface[0] != '\0') ? " on interface " : "",  \
                  (interface && interface[0] != '\0') ? interface : ""
 
 //----------------------------------------------------------------------------
 
 static inline void
@@ -434,17 +438,17 @@ HostDB_ClearEntry(PLDHashTable *table,
     nsHostDBEnt *he = static_cast<nsHostDBEnt*>(entry);
     MOZ_ASSERT(he, "nsHostDBEnt is null!");
 
     nsHostRecord *hr = he->rec;
     MOZ_ASSERT(hr, "nsHostDBEnt has null host record!");
 
     LOG(("Clearing cache db entry for host [%s%s%s].\n",
          LOG_HOST(hr->host, hr->netInterface)));
-#if defined(DEBUG)
+#if defined(DEBUG) && defined(PR_LOGGING)
     {
         MutexAutoLock lock(hr->addr_info_lock);
         if (!hr->addr_info) {
             LOG(("No address info for host [%s%s%s].\n",
                  LOG_HOST(hr->host, hr->netInterface)));
         } else {
             if (!hr->mValidEnd.IsNull()) {
                 TimeDuration diff = hr->mValidEnd - TimeStamp::NowLoRes();
@@ -1043,20 +1047,22 @@ nsHostResolver::ConditionallyCreateThrea
                                         PR_UNJOINABLE_THREAD,
                                         0);
         if (!thr) {
             mThreadCount--;
             NS_RELEASE_THIS();
             return NS_ERROR_OUT_OF_MEMORY;
         }
     }
+#if defined(PR_LOGGING)
     else {
         LOG(("  Unable to find a thread for looking up host [%s%s%s].\n",
              LOG_HOST(rec->host, rec->netInterface)));
     }
+#endif
     return NS_OK;
 }
 
 nsresult
 nsHostResolver::IssueLookup(nsHostRecord *rec)
 {
     MOZ_EVENT_TRACER_WAIT(rec, "net::dns::resolve");
 
@@ -1486,18 +1492,20 @@ nsHostResolver::ThreadFunc(void *arg)
 }
 
 nsresult
 nsHostResolver::Create(uint32_t maxCacheEntries,
                        uint32_t defaultCacheEntryLifetime,
                        uint32_t defaultGracePeriod,
                        nsHostResolver **result)
 {
+#if defined(PR_LOGGING)
     if (!gHostResolverLog)
         gHostResolverLog = PR_NewLogModule("nsHostResolver");
+#endif
 
     nsHostResolver *res = new nsHostResolver(maxCacheEntries, defaultCacheEntryLifetime,
                                              defaultGracePeriod);
     if (!res)
         return NS_ERROR_OUT_OF_MEMORY;
     NS_ADDREF(res);
 
     nsresult rv = res->Init();
--- a/netwerk/protocol/ftp/nsFTPChannel.cpp
+++ b/netwerk/protocol/ftp/nsFTPChannel.cpp
@@ -5,17 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsFTPChannel.h"
 #include "nsFtpConnectionThread.h"  // defines nsFtpState
 
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo* gFTPLog;
+#endif /* PR_LOGGING */
 
 // There are two transport connections established for an 
 // ftp connection. One is used for the command channel , and
 // the other for the data channel. The command channel is the first
 // connection made and is used to negotiate the second, data, channel.
 // The data channel is driven by the command channel and is either
 // initiated by the server (PORT command) or by the client (PASV command).
 // Client initiation is the most common case and is attempted first.
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -40,17 +40,19 @@
 #include "nsIURI.h"
 #include "nsILoadInfo.h"
 #include "nsNullPrincipal.h"
 
 #ifdef MOZ_WIDGET_GONK
 #include "NetStatistics.h"
 #endif
 
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo* gFTPLog;
+#endif
 #define LOG(args)         PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
 #define LOG_ALWAYS(args)  PR_LOG(gFTPLog, PR_LOG_ALWAYS, args)
 
 using namespace mozilla::net;
 
 // remove FTP parameters (starting with ";") from the path
 static void
 removeParamsFromPath(nsCString& path)
--- a/netwerk/protocol/ftp/nsFtpControlConnection.cpp
+++ b/netwerk/protocol/ftp/nsFtpControlConnection.cpp
@@ -10,17 +10,19 @@
 #include "nsIInputStream.h"
 #include "nsISocketTransportService.h"
 #include "nsISocketTransport.h"
 #include "nsThreadUtils.h"
 #include "nsIOutputStream.h"
 #include "nsNetCID.h"
 #include <algorithm>
 
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo* gFTPLog;
+#endif
 #define LOG(args)         PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
 #define LOG_ALWAYS(args)  PR_LOG(gFTPLog, PR_LOG_ALWAYS, args)
 
 //
 // nsFtpControlConnection implementation ...
 //
 
 NS_IMPL_ISUPPORTS(nsFtpControlConnection, nsIInputStreamCallback)
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp
@@ -29,28 +29,30 @@ using namespace mozilla::net;
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIObserverService.h"
 #include "nsEscape.h"
 #include "nsAlgorithm.h"
 
 //-----------------------------------------------------------------------------
 
+#if defined(PR_LOGGING)
 //
 // Log module for FTP Protocol logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsFtp:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables PR_LOG_DEBUG level information and places all output in
 // the file nspr.log
 //
 PRLogModuleInfo* gFTPLog = nullptr;
+#endif
 #undef LOG
 #define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args)
 
 //-----------------------------------------------------------------------------
 
 #define IDLE_TIMEOUT_PREF     "network.ftp.idleConnectionTimeout"
 #define IDLE_CONNECTION_LIMIT 8 /* TODO pref me */
 
@@ -62,19 +64,20 @@ nsFtpProtocolHandler *gFtpHandler = null
 //-----------------------------------------------------------------------------
 
 nsFtpProtocolHandler::nsFtpProtocolHandler()
     : mIdleTimeout(-1)
     , mSessionId(0)
     , mControlQoSBits(0x00)
     , mDataQoSBits(0x00)
 {
+#if defined(PR_LOGGING)
     if (!gFTPLog)
         gFTPLog = PR_NewLogModule("nsFtp");
-
+#endif
     LOG(("FTP:creating handler @%x\n", this));
 
     gFtpHandler = this;
 }
 
 nsFtpProtocolHandler::~nsFtpProtocolHandler()
 {
     LOG(("FTP:destroying handler @%x\n", this));
--- a/netwerk/protocol/ftp/nsFtpProtocolHandler.h
+++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h
@@ -77,11 +77,13 @@ private:
     uint8_t mControlQoSBits;
     uint8_t mDataQoSBits;
 };
 
 //-----------------------------------------------------------------------------
 
 extern nsFtpProtocolHandler *gFtpHandler;
 
+#ifdef PR_LOGGING
 extern PRLogModuleInfo* gFTPLog;
+#endif
 
 #endif // !nsFtpProtocolHandler_h__
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -2351,27 +2351,26 @@ HttpBaseChannel::SetupReplacementChannel
     if (mRedirectedCachekeys) {
         LOG(("HttpBaseChannel::SetupReplacementChannel "
              "[this=%p] transferring chain of redirect cache-keys", this));
         httpInternal->SetCacheKeysRedirectChain(mRedirectedCachekeys.forget());
     }
     // Transfer existing redirect information. Add all of our existing
     // redirects to the new channel.
     for (int32_t i = 0; i < mRedirects.Count(); ++i) {
-      if (LOG_ENABLED()) {
-        nsCOMPtr<nsIURI> uri;
-        mRedirects[i]->GetURI(getter_AddRefs(uri));
-        nsCString spec;
-        if (uri) {
-          uri->GetSpec(spec);
-        }
-        LOG(("HttpBaseChannel::SetupReplacementChannel adding redirect \'%s\' "
-             "[this=%p]", spec.get(), this));
+#ifdef PR_LOGGING
+      nsCOMPtr<nsIURI> uri;
+      mRedirects[i]->GetURI(getter_AddRefs(uri));
+      nsCString spec;
+      if (uri) {
+        uri->GetSpec(spec);
       }
-
+      LOG(("HttpBaseChannel::SetupReplacementChannel adding redirect \'%s\' "
+           "[this=%p]", spec.get(), this));
+#endif
       httpInternal->AddRedirect(mRedirects[i]);
     }
 
     // Add our own principal to the redirect information on the new channel. If
     // the redirect is vetoed, then newChannel->AsyncOpen won't be called.
     // However, the new channel's redirect chain will still be complete.
     nsCOMPtr<nsIPrincipal> principal = GetURIPrincipal();
     httpInternal->AddRedirect(principal);
--- a/netwerk/protocol/http/HttpLog.h
+++ b/netwerk/protocol/http/HttpLog.h
@@ -18,28 +18,30 @@
  *  Yes, this is kludgy.
  *******************************************************************************/
 
 #include "mozilla/net/NeckoChild.h"
 
 // Get rid of Chromium's LOG definition
 #undef LOG
 
+#if defined(PR_LOGGING)
 //
 // Log module for HTTP Protocol logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsHttp:5
 //    set NSPR_LOG_FILE=http.log
 //
 // this enables PR_LOG_ALWAYS level information and places all output in
 // the file http.log
 //
 extern PRLogModuleInfo *gHttpLog;
+#endif
 
 // http logging
 #define LOG1(args) PR_LOG(gHttpLog, 1, args)
 #define LOG2(args) PR_LOG(gHttpLog, 2, args)
 #define LOG3(args) PR_LOG(gHttpLog, 3, args)
 #define LOG4(args) PR_LOG(gHttpLog, 4, args)
 #define LOG5(args) PR_LOG(gHttpLog, 5, args)
 #define LOG(args) LOG4(args)
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -8,17 +8,19 @@
 #include "HttpLog.h"
 
 #include "nsHttp.h"
 #include "pldhash.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/HashFunctions.h"
 #include "nsCRT.h"
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo *gHttpLog = nullptr;
+#endif
 
 namespace mozilla {
 namespace net {
 
 // define storage for all atoms
 #define HTTP_ATOM(_name, _value) nsHttpAtom nsHttp::_name = { _value };
 #include "nsHttpAtomList.h"
 #undef HTTP_ATOM
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6553,22 +6553,22 @@ nsHttpChannel::MaybeInvalidateCacheEntry
     // any cached copy of the resource
     if (mRequestHead.IsGet() || mRequestHead.IsOptions() ||
         mRequestHead.IsHead() || mRequestHead.IsTrace() ||
         mRequestHead.IsConnect()) {
         return;
     }
 
     // Invalidate the request-uri.
-    if (LOG_ENABLED()) {
-      nsAutoCString key;
-      mURI->GetAsciiSpec(key);
-      LOG(("MaybeInvalidateCacheEntryForSubsequentGet [this=%p uri=%s]\n",
-          this, key.get()));
-    }
+#ifdef PR_LOGGING
+    nsAutoCString key;
+    mURI->GetAsciiSpec(key);
+    LOG(("MaybeInvalidateCacheEntryForSubsequentGet [this=%p uri=%s]\n",
+        this, key.get()));
+#endif
 
     DoInvalidateCacheEntry(mURI);
 
     // Invalidate Location-header if set
     const char *location = mResponseHead->PeekHeader(nsHttp::Location);
     if (location) {
         LOG(("  Location-header=%s\n", location));
         InvalidateCacheEntryForLocation(location);
@@ -6601,22 +6601,21 @@ nsHttpChannel::DoInvalidateCacheEntry(ns
     // NOTE:
     // Following comments 24,32 and 33 in bug #327765, we only care about
     // the cache in the protocol-handler, not the application cache.
     // The logic below deviates from the original logic in OpenCacheEntry on
     // one point by using only READ_ONLY access-policy. I think this is safe.
 
     nsresult rv;
 
+#ifdef PR_LOGGING
     nsAutoCString key;
-    if (LOG_ENABLED()) {
-      aURI->GetAsciiSpec(key);
-    }
-
+    aURI->GetAsciiSpec(key);
     LOG(("DoInvalidateCacheEntry [channel=%p key=%s]", this, key.get()));
+#endif
 
     nsCOMPtr<nsICacheStorageService> cacheStorageService =
         do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv);
 
     nsCOMPtr<nsICacheStorage> cacheStorage;
     if (NS_SUCCEEDED(rv)) {
         nsRefPtr<LoadContextInfo> info = GetLoadContextInfo(this);
         rv = cacheStorageService->DiskCacheStorage(info, false, getter_AddRefs(cacheStorage));
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -209,17 +209,19 @@ nsHttpHandler::nsHttpHandler()
     , mCriticalRequestPrioritization(true)
     , mTCPKeepaliveShortLivedEnabled(false)
     , mTCPKeepaliveShortLivedTimeS(60)
     , mTCPKeepaliveShortLivedIdleTimeS(10)
     , mTCPKeepaliveLongLivedEnabled(false)
     , mTCPKeepaliveLongLivedIdleTimeS(600)
     , mEnforceH1Framing(FRAMECHECK_BARELY)
 {
+#if defined(PR_LOGGING)
     gHttpLog = PR_NewLogModule("nsHttp");
+#endif
 
     LOG(("Creating nsHttpHandler [this=%p].\n", this));
 
     RegisterStrongMemoryReporter(new SpdyZlibReporter());
 
     MOZ_ASSERT(!gHttpHandler, "HTTP handler already created!");
     gHttpHandler = this;
 }
--- a/netwerk/protocol/http/nsHttpNTLMAuth.cpp
+++ b/netwerk/protocol/http/nsHttpNTLMAuth.cpp
@@ -269,18 +269,20 @@ nsHttpNTLMAuth::ChallengeReceived(nsIHtt
                 // username, and password. (only supported by windows nsAuthSSPI module.)
                 // Note, for servers that use LMv1 a weak hash of the user's password
                 // will be sent. We rely on windows internal apis to decide whether
                 // we should support this older, less secure version of the protocol.
                 module = do_CreateInstance(NS_AUTH_MODULE_CONTRACTID_PREFIX "sys-ntlm");
                 *identityInvalid = true;
             }
 #endif // XP_WIN
+#ifdef PR_LOGGING
             if (!module)
                 LOG(("Native sys-ntlm auth module not found.\n"));
+#endif
         }
 
 #ifdef XP_WIN
         // On windows, never fall back unless the user has specifically requested so.
         if (!forceGeneric && !module)
             return NS_ERROR_UNEXPECTED;
 #endif
 
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -58,16 +58,17 @@ using namespace mozilla::net;
 
 namespace mozilla {
 namespace net {
 
 //-----------------------------------------------------------------------------
 // helpers
 //-----------------------------------------------------------------------------
 
+#if defined(PR_LOGGING)
 static void
 LogHeaders(const char *lineStart)
 {
     nsAutoCString buf;
     char *endOfLine;
     while ((endOfLine = PL_strstr(lineStart, "\r\n"))) {
         buf.Assign(lineStart, endOfLine - lineStart);
         if (PL_strcasestr(buf.get(), "authorization: ") ||
@@ -75,16 +76,17 @@ LogHeaders(const char *lineStart)
             char *p = PL_strchr(PL_strchr(buf.get(), ' ') + 1, ' ');
             while (p && *++p)
                 *p = '*';
         }
         LOG3(("  %s\n", buf.get()));
         lineStart = endOfLine + 2;
     }
 }
+#endif
 
 //-----------------------------------------------------------------------------
 // nsHttpTransaction <public>
 //-----------------------------------------------------------------------------
 
 nsHttpTransaction::nsHttpTransaction()
     : mLock("transaction lock")
     , mRequestSize(0)
@@ -313,21 +315,23 @@ nsHttpTransaction::Init(uint32_t caps,
 
     // make sure we eliminate any proxy specific headers from
     // the request if we are using CONNECT
     bool pruneProxyHeaders = cinfo->UsingConnect();
 
     mReqHeaderBuf.Truncate();
     requestHead->Flatten(mReqHeaderBuf, pruneProxyHeaders);
 
+#if defined(PR_LOGGING)
     if (LOG3_ENABLED()) {
         LOG3(("http request [\n"));
         LogHeaders(mReqHeaderBuf.get());
         LOG3(("]\n"));
     }
+#endif
 
     // If the request body does not include headers or if there is no request
     // body, then we must add the header/body separator manually.
     if (!requestBodyHasHeaders || !requestBody)
         mReqHeaderBuf.AppendLiteral("\r\n");
 
     // report the request header
     if (mActivityDistributor)
@@ -1465,24 +1469,25 @@ nsHttpTransaction::ParseHead(char *buf,
 
 nsresult
 nsHttpTransaction::HandleContentStart()
 {
     LOG(("nsHttpTransaction::HandleContentStart [this=%p]\n", this));
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
     if (mResponseHead) {
+#if defined(PR_LOGGING)
         if (LOG3_ENABLED()) {
             LOG3(("http response [\n"));
             nsAutoCString headers;
             mResponseHead->Flatten(headers, false);
             LogHeaders(headers.get());
             LOG3(("]\n"));
         }
-
+#endif
         // Save http version, mResponseHead isn't available anymore after
         // TakeResponseHead() is called
         mHttpVersion = mResponseHead->Version();
 
         // notify the connection, give it a chance to cause a reset.
         bool reset = false;
         if (!mRestartInProgressVerifier.IsSetup())
             mConnection->OnHeadersAvailable(this, mRequestHead, mResponseHead, &reset);
@@ -1551,18 +1556,20 @@ nsHttpTransaction::HandleContentStart()
                 // we only support the "chunked" transfer encoding right now.
                 mChunkedDecoder = new nsHttpChunkedDecoder();
                 if (!mChunkedDecoder)
                     return NS_ERROR_OUT_OF_MEMORY;
                 LOG(("chunked decoder created\n"));
                 // Ignore server specified Content-Length.
                 mContentLength = -1;
             }
+#if defined(PR_LOGGING)
             else if (mContentLength == int64_t(-1))
                 LOG(("waiting for the server to close the connection.\n"));
+#endif
         }
         if (mRestartInProgressVerifier.IsSetup() &&
             !mRestartInProgressVerifier.Verify(mContentLength, mResponseHead)) {
             LOG(("Restart in progress subsequent transaction failed to match"));
             return NS_ERROR_ABORT;
         }
     }
 
--- a/netwerk/protocol/res/nsResProtocolHandler.cpp
+++ b/netwerk/protocol/res/nsResProtocolHandler.cpp
@@ -18,28 +18,30 @@
 
 using mozilla::dom::ContentParent;
 using mozilla::unused;
 
 static NS_DEFINE_CID(kResURLCID, NS_RESURL_CID);
 
 static nsResProtocolHandler *gResHandler = nullptr;
 
+#if defined(PR_LOGGING)
 //
 // Log module for Resource Protocol logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsResProtocol:5
 //    set NSPR_LOG_FILE=log.txt
 //
 // this enables PR_LOG_ALWAYS level information and places all output in
 // the file log.txt
 //
 static PRLogModuleInfo *gResLog;
+#endif
 
 #define kAPP           NS_LITERAL_CSTRING("app")
 #define kGRE           NS_LITERAL_CSTRING("gre")
 
 //----------------------------------------------------------------------------
 // nsResURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
 //----------------------------------------------------------------------------
 
@@ -97,17 +99,19 @@ nsResURL::GetClassIDNoAlloc(nsCID *aClas
 
 //----------------------------------------------------------------------------
 // nsResProtocolHandler <public>
 //----------------------------------------------------------------------------
 
 nsResProtocolHandler::nsResProtocolHandler()
     : mSubstitutions(16)
 {
+#if defined(PR_LOGGING)
     gResLog = PR_NewLogModule("nsResProtocol");
+#endif
 
     NS_ASSERTION(!gResHandler, "res handler already created!");
     gResHandler = this;
 }
 
 nsResProtocolHandler::~nsResProtocolHandler()
 {
     gResHandler = nullptr;
@@ -442,16 +446,18 @@ nsResProtocolHandler::ResolveURI(nsIURI 
         return NS_ERROR_MALFORMED_URI;
 
     nsCOMPtr<nsIURI> baseURI;
     rv = GetSubstitution(host, getter_AddRefs(baseURI));
     if (NS_FAILED(rv)) return rv;
 
     rv = baseURI->Resolve(nsDependentCString(p, path.Length()-1), result);
 
+#if defined(PR_LOGGING)
     if (PR_LOG_TEST(gResLog, PR_LOG_DEBUG)) {
         nsAutoCString spec;
         uri->GetAsciiSpec(spec);
         PR_LOG(gResLog, PR_LOG_DEBUG,
                ("%s\n -> %s\n", spec.get(), PromiseFlatCString(result).get()));
     }
+#endif
     return rv;
 }
--- a/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp
+++ b/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp
@@ -65,18 +65,20 @@ RtspControllerChild::RtspControllerChild
   , mIPCAllowed(false)
   , mChannel(channel)
   , mTotalTracks(0)
   , mSuspendCount(0)
   , mTimerLock("RtspControllerChild.mTimerLock")
   , mPlayTimer(nullptr)
   , mPauseTimer(nullptr)
 {
+#if defined(PR_LOGGING)
   if (!gRtspChildLog)
     gRtspChildLog = PR_NewLogModule("nsRtspChild");
+#endif
   AddIPDLReference();
   gNeckoChild->SendPRtspControllerConstructor(this);
 }
 
 RtspControllerChild::~RtspControllerChild()
 {
   LOG(("RtspControllerChild::~RtspControllerChild()"));
 }
--- a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp
+++ b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp
@@ -57,18 +57,20 @@ NS_IMPL_ADDREF(RtspControllerParent)
 NS_IMPL_RELEASE_WITH_DESTROY(RtspControllerParent, Destroy())
 NS_IMPL_QUERY_INTERFACE(RtspControllerParent,
                         nsIStreamingProtocolListener)
 
 RtspControllerParent::RtspControllerParent()
   : mIPCOpen(true)
   , mTotalTracks(0)
 {
+#if defined(PR_LOGGING)
   if (!gRtspLog)
     gRtspLog = PR_NewLogModule("nsRtsp");
+#endif
 }
 
 RtspControllerParent::~RtspControllerParent()
 {
 }
 
 void
 RtspControllerParent::ActorDestroy(ActorDestroyReason why)
--- a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp
@@ -8,32 +8,36 @@
 #include "BaseWebSocketChannel.h"
 #include "MainThreadUtils.h"
 #include "nsILoadGroup.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsAutoPtr.h"
 #include "nsProxyRelease.h"
 #include "nsStandardURL.h"
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo *webSocketLog = nullptr;
+#endif
 
 namespace mozilla {
 namespace net {
 
 BaseWebSocketChannel::BaseWebSocketChannel()
   : mEncrypted(0)
   , mWasOpened(0)
   , mClientSetPingInterval(0)
   , mClientSetPingTimeout(0)
   , mPingForced(0)
   , mPingInterval(0)
   , mPingResponseTimeout(10000)
 {
+#if defined(PR_LOGGING)
   if (!webSocketLog)
     webSocketLog = PR_NewLogModule("nsWebSocket");
+#endif
 }
 
 //-----------------------------------------------------------------------------
 // BaseWebSocketChannel::nsIWebSocketChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 BaseWebSocketChannel::GetOriginalURI(nsIURI **aOriginalURI)
--- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp
@@ -28,18 +28,20 @@ WebSocketChannelParent::WebSocketChannel
                                                nsILoadContext* aLoadContext,
                                                PBOverrideStatus aOverrideStatus)
   : mAuthProvider(aAuthProvider)
   , mLoadContext(aLoadContext)
   , mIPCOpen(true)
 {
   // Websocket channels can't have a private browsing override
   MOZ_ASSERT_IF(!aLoadContext, aOverrideStatus == kPBOverride_Unset);
+#if defined(PR_LOGGING)
   if (!webSocketLog)
     webSocketLog = PR_NewLogModule("nsWebSocket");
+#endif
   mObserver = new OfflineObserver(this);
 }
 
 WebSocketChannelParent::~WebSocketChannelParent()
 {
   if (mObserver) {
     mObserver->RemoveObserver();
   }
--- a/netwerk/protocol/websocket/WebSocketLog.h
+++ b/netwerk/protocol/websocket/WebSocketLog.h
@@ -6,14 +6,16 @@
 
 #ifndef WebSocketLog_h
 #define WebSocketLog_h
 
 #include "base/basictypes.h"
 #include "prlog.h"
 #include "mozilla/net/NeckoChild.h"
 
+#ifdef PR_LOGGING
 extern PRLogModuleInfo* webSocketLog;
+#endif
 
 #undef LOG
 #define LOG(args) PR_LOG(webSocketLog, PR_LOG_DEBUG, args)
 
 #endif
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
@@ -20,18 +20,20 @@ using namespace mozilla::ipc;
 
 namespace mozilla {
 namespace net {
 
 WyciwygChannelParent::WyciwygChannelParent()
  : mIPCClosed(false)
  , mReceivedAppData(false)
 {
+#if defined(PR_LOGGING)
   if (!gWyciwygLog)
     gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
+#endif
 }
 
 WyciwygChannelParent::~WyciwygChannelParent()
 {
 }
 
 void
 WyciwygChannelParent::ActorDestroy(ActorDestroyReason why)
--- a/netwerk/protocol/wyciwyg/nsWyciwyg.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwyg.cpp
@@ -1,9 +1,11 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWyciwyg.h"
 #include "nscore.h"
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo *gWyciwygLog = nullptr;
+#endif
 
--- a/netwerk/protocol/wyciwyg/nsWyciwyg.h
+++ b/netwerk/protocol/wyciwyg/nsWyciwyg.h
@@ -7,28 +7,30 @@
 
 #include "mozilla/net/NeckoChild.h"
 
 // Get rid of chromium's LOG.
 #undef LOG
 
 #include "prlog.h"
 
+#if defined(PR_LOGGING)
 //
 // Log module for HTTP Protocol logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsWyciwyg:5
 //    set NSPR_LOG_FILE=wyciwyg.log
 //
 // this enables PR_LOG_ALWAYS level information and places all output in
 // the file wyciwyg.log
 //
 extern PRLogModuleInfo *gWyciwygLog;
+#endif
 
 // http logging
 #define LOG1(args) PR_LOG(gWyciwygLog, 1, args)
 #define LOG2(args) PR_LOG(gWyciwygLog, 2, args)
 #define LOG3(args) PR_LOG(gWyciwygLog, 3, args)
 #define LOG4(args) PR_LOG(gWyciwygLog, 4, args)
 #define LOG(args) LOG4(args)
 
--- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
@@ -18,18 +18,20 @@
 
 using namespace mozilla::net;
 #include "mozilla/net/WyciwygChannelChild.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 
 nsWyciwygProtocolHandler::nsWyciwygProtocolHandler() 
 {
+#if defined(PR_LOGGING)
   if (!gWyciwygLog)
     gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
+#endif
 
   LOG(("Creating nsWyciwygProtocolHandler [this=%p].\n", this));
 }
 
 nsWyciwygProtocolHandler::~nsWyciwygProtocolHandler() 
 {
   LOG(("Deleting nsWyciwygProtocolHandler [this=%p]\n", this));
 }
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -45,16 +45,17 @@
 #ifdef MOZ_PEERCONNECTION
 #include "mtransport/runnable_utils.h"
 #endif
 
 #define DATACHANNEL_LOG(args) LOG(args)
 #include "DataChannel.h"
 #include "DataChannelProtocol.h"
 
+#ifdef PR_LOGGING
 PRLogModuleInfo*
 GetDataChannelLog()
 {
   static PRLogModuleInfo* sLog;
   if (!sLog)
     sLog = PR_NewLogModule("DataChannel");
   return sLog;
 }
@@ -62,16 +63,17 @@ GetDataChannelLog()
 PRLogModuleInfo*
 GetSCTPLog()
 {
   static PRLogModuleInfo* sLog;
   if (!sLog)
     sLog = PR_NewLogModule("SCTP");
   return sLog;
 }
+#endif
 
 // Let us turn on and off important assertions in non-debug builds
 #ifdef DEBUG
 #define ASSERT_WEBRTC(x) MOZ_ASSERT((x))
 #elif defined(MOZ_WEBRTC_ASSERT_ALWAYS)
 #define ASSERT_WEBRTC(x) do { if (!(x)) { MOZ_CRASH(); } } while (0)
 #endif
 
@@ -167,16 +169,17 @@ static int
 receive_cb(struct socket* sock, union sctp_sockstore addr,
            void *data, size_t datalen,
            struct sctp_rcvinfo rcv, int flags, void *ulp_info)
 {
   DataChannelConnection *connection = static_cast<DataChannelConnection*>(ulp_info);
   return connection->ReceiveCallback(sock, data, datalen, rcv, flags);
 }
 
+#ifdef PR_LOGGING
 static void
 debug_printf(const char *format, ...)
 {
   va_list ap;
   char buffer[1024];
 
   if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_ALWAYS)) {
     va_start(ap, format);
@@ -185,16 +188,17 @@ debug_printf(const char *format, ...)
 #else
     if (vsnprintf(buffer, sizeof(buffer), format, ap) > 0) {
 #endif
       PR_LogPrint("%s", buffer);
     }
     va_end(ap);
   }
 }
+#endif
 
 DataChannelConnection::DataChannelConnection(DataConnectionListener *listener) :
    mLock("netwerk::sctp::DataChannelConnection")
 {
   mState = CLOSED;
   mSocket = nullptr;
   mMasterSocket = nullptr;
   mListener = listener;
@@ -316,34 +320,43 @@ DataChannelConnection::Init(unsigned sho
 
     // MutexAutoLock lock(mLock); Not needed since we're on mainthread always
     if (!sctp_initialized) {
       if (aUsingDtls) {
         LOG(("sctp_init(DTLS)"));
 #ifdef MOZ_PEERCONNECTION
         usrsctp_init(0,
                      DataChannelConnection::SctpDtlsOutput,
+#ifdef PR_LOGGING
                      debug_printf
+#else
+                     nullptr
+#endif
                     );
 #else
         NS_ASSERTION(!aUsingDtls, "Trying to use SCTP/DTLS without mtransport");
 #endif
       } else {
         LOG(("sctp_init(%u)", aPort));
         usrsctp_init(aPort,
                      nullptr,
+#ifdef PR_LOGGING
                      debug_printf
+#else
+                     nullptr
+#endif
                     );
       }
 
+#ifdef PR_LOGGING
       // Set logging to SCTP:PR_LOG_DEBUG to get SCTP debugs
       if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_ALWAYS)) {
         usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
       }
-
+#endif
       usrsctp_sysctl_set_sctp_blackhole(2);
       // ECN is currently not supported by the Firefox code
       usrsctp_sysctl_set_sctp_ecn_enable(0);
       sctp_initialized = true;
 
       gDataChannelShutdown = new DataChannelShutdown();
       gDataChannelShutdown->Init();
     }
@@ -648,24 +661,26 @@ DataChannelConnection::ProcessQueuedOpen
     }
   }
 
 }
 void
 DataChannelConnection::SctpDtlsInput(TransportFlow *flow,
                                      const unsigned char *data, size_t len)
 {
+#ifdef PR_LOGGING
   if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_DEBUG)) {
     char *buf;
 
     if ((buf = usrsctp_dumppacket((void *)data, len, SCTP_DUMP_INBOUND)) != nullptr) {
       PR_LogPrint("%s", buf);
       usrsctp_freedumpbuffer(buf);
     }
   }
+#endif
   // Pass the data to SCTP
   usrsctp_conninput(static_cast<void *>(this), data, len, 0);
 }
 
 int
 DataChannelConnection::SendPacket(unsigned char data[], size_t len, bool release)
 {
   //LOG(("%p: SCTP/DTLS sent %ld bytes", this, len));
@@ -678,24 +693,26 @@ DataChannelConnection::SendPacket(unsign
 /* static */
 int
 DataChannelConnection::SctpDtlsOutput(void *addr, void *buffer, size_t length,
                                       uint8_t tos, uint8_t set_df)
 {
   DataChannelConnection *peer = static_cast<DataChannelConnection *>(addr);
   int res;
 
+#ifdef PR_LOGGING
   if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_DEBUG)) {
     char *buf;
 
     if ((buf = usrsctp_dumppacket(buffer, length, SCTP_DUMP_OUTBOUND)) != nullptr) {
       PR_LogPrint("%s", buf);
       usrsctp_freedumpbuffer(buf);
     }
   }
+#endif
   // We're async proxying even if on the STSThread because this is called
   // with internal SCTP locks held in some cases (such as in usrsctp_connect()).
   // SCTP has an option for Apple, on IP connections only, to release at least
   // one of the locks before calling a packet output routine; with changes to
   // the underlying SCTP stack this might remove the need to use an async proxy.
   if (0 /*peer->IsSTSThread()*/) {
     res = peer->SendPacket(static_cast<unsigned char *>(buffer), length, false);
   } else {
--- a/netwerk/sctp/datachannel/DataChannelLog.h
+++ b/netwerk/sctp/datachannel/DataChannelLog.h
@@ -5,15 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DataChannelLog_h
 #define DataChannelLog_h
 
 #include "base/basictypes.h"
 #include "prlog.h"
 
+#ifdef PR_LOGGING
 extern PRLogModuleInfo* GetDataChannelLog();
 extern PRLogModuleInfo* GetSCTPLog();
+#endif
 
 #undef LOG
 #define LOG(args) PR_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args)
 
 #endif
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -23,20 +23,26 @@
 
 using namespace mozilla::net;
 
 static PRDescIdentity nsSOCKSIOLayerIdentity;
 static PRIOMethods nsSOCKSIOLayerMethods;
 static bool firstTime = true;
 static bool ipv6Supported = true;
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gSOCKSLog;
 #define LOGDEBUG(args) PR_LOG(gSOCKSLog, PR_LOG_DEBUG, args)
 #define LOGERROR(args) PR_LOG(gSOCKSLog, PR_LOG_ERROR , args)
 
+#else
+#define LOGDEBUG(args)
+#define LOGERROR(args)
+#endif
+
 class nsSOCKSSocketInfo : public nsISOCKSSocketInfo
                         , public nsIDNSListener
 {
     enum State {
         SOCKS_INITIAL,
         SOCKS_DNS_IN_PROGRESS,
         SOCKS_DNS_COMPLETE,
         SOCKS_CONNECTING_TO_PROXY,
@@ -418,23 +424,22 @@ nsSOCKSSocketInfo::ConnectToProxy(PRFile
         rv = mDnsRec->GetNextAddr(mProxyPort, &mInternalProxyAddr);
         // No more addresses to try? If so, we'll need to bail
         if (NS_FAILED(rv)) {
             LOGERROR(("socks: unable to connect to SOCKS proxy, %s",
                      mProxyHost.get()));
             return PR_FAILURE;
         }
 
-        if (PR_LOG_TEST(gSOCKSLog, PR_LOG_DEBUG)) {
-          char buf[kIPv6CStrBufSize];
-          NetAddrToString(&mInternalProxyAddr, buf, sizeof(buf));
-          LOGDEBUG(("socks: trying proxy server, %s:%hu",
-                   buf, ntohs(mInternalProxyAddr.inet.port)));
-        }
-
+#if defined(PR_LOGGING)
+        char buf[kIPv6CStrBufSize];
+        NetAddrToString(&mInternalProxyAddr, buf, sizeof(buf));
+        LOGDEBUG(("socks: trying proxy server, %s:%hu",
+                 buf, ntohs(mInternalProxyAddr.inet.port)));
+#endif
         NetAddr proxy = mInternalProxyAddr;
         FixupAddressFamily(fd, &proxy);
         PRNetAddr prProxy;
         NetAddrToPRNetAddr(&proxy, &prProxy);
         status = fd->lower->methods->connect(fd->lower, &prProxy, mTimeout);
         if (status != PR_SUCCESS) {
             PRErrorCode c = PR_GetError();
             // If EINPROGRESS, return now and check back later after polling
@@ -1301,17 +1306,20 @@ nsSOCKSIOLayerAddToSocket(int32_t family
         nsSOCKSIOLayerMethods.getsockname = nsSOCKSIOLayerGetName;
         nsSOCKSIOLayerMethods.getpeername = nsSOCKSIOLayerGetPeerName;
         nsSOCKSIOLayerMethods.accept = nsSOCKSIOLayerAccept;
         nsSOCKSIOLayerMethods.listen = nsSOCKSIOLayerListen;
         nsSOCKSIOLayerMethods.close = nsSOCKSIOLayerClose;
 
         firstTime = false;
 
+#if defined(PR_LOGGING)
         gSOCKSLog = PR_NewLogModule("SOCKS");
+#endif
+
     }
 
     LOGDEBUG(("Entering nsSOCKSIOLayerAddToSocket()."));
 
     PRFileDesc *layer;
     PRStatus rv;
 
     layer = PR_CreateIOLayerStub(nsSOCKSIOLayerIdentity, &nsSOCKSIOLayerMethods);
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -14,29 +14,31 @@
 #include "nsCRT.h"
 #include "nsAutoPtr.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 
 #include "ParseFTPList.h"
 #include <algorithm>
 
+#if defined(PR_LOGGING)
 //
 // Log module for FTP dir listing stream converter logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsFTPDirListConv:5
 //    set NSPR_LOG_FILE=nspr.log
 //
 // this enables PR_LOG_DEBUG level information and places all output in
 // the file nspr.log
 //
 PRLogModuleInfo* gFTPDirListConvLog = nullptr;
 
+#endif /* PR_LOGGING */
 
 // nsISupports implementation
 NS_IMPL_ISUPPORTS(nsFTPDirListingConv,
                   nsIStreamConverter,
                   nsIStreamListener, 
                   nsIRequestObserver)
 
 
@@ -186,23 +188,25 @@ nsFTPDirListingConv::nsFTPDirListingConv
 }
 
 nsFTPDirListingConv::~nsFTPDirListingConv() {
     NS_IF_RELEASE(mFinalListener);
 }
 
 nsresult
 nsFTPDirListingConv::Init() {
+#if defined(PR_LOGGING)
     //
     // Initialize the global PRLogModule for FTP Protocol logging 
     // if necessary...
     //
     if (nullptr == gFTPDirListConvLog) {
         gFTPDirListConvLog = PR_NewLogModule("nsFTPDirListingConv");
     }
+#endif /* PR_LOGGING */
 
     return NS_OK;
 }
 
 nsresult
 nsFTPDirListingConv::GetHeaders(nsACString& headers,
                                 nsIURI* uri)
 {
--- a/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
+++ b/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
@@ -33,18 +33,22 @@
 #include <cutils/properties.h>
 #endif
 
 /* a shorter name that better explains what it does */
 #define EINTR_RETRY(x) MOZ_TEMP_FAILURE_RETRY(x)
 
 using namespace mozilla;
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gNotifyAddrLog = nullptr;
 #define LOG(args) PR_LOG(gNotifyAddrLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 #define NETWORK_NOTIFY_CHANGED_PREF "network.notify.changed"
 
 NS_IMPL_ISUPPORTS(nsNotifyAddrListener,
                   nsINetworkLinkService,
                   nsIRunnable,
                   nsIObserver)
 
@@ -294,18 +298,20 @@ class NuwaMarkLinkMonitorThreadRunner : 
         return NS_OK;
     }
 };
 #endif
 
 nsresult
 nsNotifyAddrListener::Init(void)
 {
+#if defined(PR_LOGGING)
     if (!gNotifyAddrLog)
         gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr");
+#endif
 
     nsCOMPtr<nsIObserverService> observerService =
         mozilla::services::GetObserverService();
     if (!observerService)
         return NS_ERROR_FAILURE;
 
     nsresult rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
                                                false);
--- a/netwerk/system/win32/nsNotifyAddrListener.cpp
+++ b/netwerk/system/win32/nsNotifyAddrListener.cpp
@@ -29,18 +29,22 @@
 #include "nsCRT.h"
 #include "mozilla/Preferences.h"
 
 #include <iptypes.h>
 #include <iphlpapi.h>
 
 using namespace mozilla;
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gNotifyAddrLog = nullptr;
 #define LOG(args) PR_LOG(gNotifyAddrLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 static HMODULE sNetshell;
 static decltype(NcFreeNetconProperties)* sNcFreeNetconProperties;
 
 static HMODULE sIphlpapi;
 static decltype(NotifyIpInterfaceChange)* sNotifyIpInterfaceChange;
 static decltype(CancelMibChangeNotify2)* sCancelMibChangeNotify2;
 
@@ -210,18 +214,20 @@ nsNotifyAddrListener::Observe(nsISupport
         Shutdown();
 
     return NS_OK;
 }
 
 nsresult
 nsNotifyAddrListener::Init(void)
 {
+#if defined(PR_LOGGING)
     if (!gNotifyAddrLog)
         gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr");
+#endif
 
     nsCOMPtr<nsIObserverService> observerService =
         mozilla::services::GetObserverService();
     if (!observerService)
         return NS_ERROR_FAILURE;
 
     nsresult rv = observerService->AddObserver(this, "xpcom-shutdown-threads",
                                                false);
--- a/netwerk/test/TestBlockingSocket.cpp
+++ b/netwerk/test/TestBlockingSocket.cpp
@@ -14,20 +14,22 @@
 #include "nsNetUtil.h"
 #include "prlog.h"
 #include "prenv.h"
 #include "prthread.h"
 #include <stdlib.h>
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -97,25 +99,29 @@ main(int argc, char* argv[])
     }
     char* hostName = argv[1];
     int32_t port = atoi(argv[2]);
     char* fileName = argv[3];
     {
         nsCOMPtr<nsIServiceManager> servMan;
         NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
 
+#if defined(PR_LOGGING)
         gTestLog = PR_NewLogModule("Test");
+#endif
 
         nsCOMPtr<nsIFile> file;
         rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file));
         if (NS_FAILED(rv)) return -1;
 
         rv = RunBlockingTest(nsDependentCString(hostName), port, file);
+#if defined(PR_LOGGING)
         if (NS_FAILED(rv))
             LOG(("RunBlockingTest failed [rv=%x]\n", rv));
+#endif
 
         // give background threads a chance to finish whatever work they may
         // be doing.
         LOG(("sleeping for 5 seconds...\n"));
         PR_Sleep(PR_SecondsToInterval(5));
     } // this scopes the nsCOMPtrs
     // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
     rv = NS_ShutdownXPCOM(nullptr);
--- a/netwerk/test/TestIOThreads.cpp
+++ b/netwerk/test/TestIOThreads.cpp
@@ -6,20 +6,22 @@
 #include "nsXPCOM.h"
 #include "nsIServiceManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIEventTarget.h"
 #include "nsCOMPtr.h"
 #include "nsNetCID.h"
 #include "prlog.h"
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 class nsIOEvent : public nsIRunnable {
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
 
     nsIOEvent(int i) : mIndex(i) {}
 
@@ -52,17 +54,19 @@ static nsresult RunTest()
 
 int main(int argc, char **argv)
 {
     if (test_common_init(&argc, &argv) != 0)
         return -1;
 
     nsresult rv;
 
+#if defined(PR_LOGGING)
     gTestLog = PR_NewLogModule("Test");
+#endif
 
     rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
     if (NS_FAILED(rv))
         return rv;
 
     rv = RunTest();
     if (NS_FAILED(rv))
         LOG(("RunTest failed [rv=%x]\n", rv));
--- a/netwerk/test/TestOverlappedIO.cpp
+++ b/netwerk/test/TestOverlappedIO.cpp
@@ -21,18 +21,22 @@
 #include "nsIStreamListener.h"
 #include "nsIPipe.h"
 #include "nsIOutputStream.h"
 #include "nsIInputStream.h"
 #include "nsCRT.h"
 #include "nsCOMPtr.h"
 #include "nsIByteArrayInputStream.h"
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gTestSocketIOLog;
 #define LOG(args) PR_LOG(gTestSocketIOLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
 static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
 
 static PRTime gElapsedTime;
 static int gKeepRunning = 1;
 static nsIEventQueue* gEventQ = nullptr;
 
@@ -224,17 +228,19 @@ usage(char **argv)
 
 int
 main(int argc, char* argv[])
 {
     nsresult rv;
 
     signal(SIGSEGV, sighandler);
 
+#if defined(PR_LOGGING)
     gTestSocketIOLog = PR_NewLogModule("TestSocketIO");
+#endif
 
     if (argc < 3)
         usage(argv);
 
     char *hostName = argv[1];
     char *fileName = argv[2];
     int port = 80;
 
--- a/netwerk/test/TestProtocols.cpp
+++ b/netwerk/test/TestProtocols.cpp
@@ -56,20 +56,22 @@
 #include "nsStringAPI.h"
 #include "nsNetUtil.h"
 #include "prlog.h"
 
 using namespace mozilla;
 
 namespace TestProtocols {
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 static NS_DEFINE_CID(kIOServiceCID,              NS_IOSERVICE_CID);
 
 //static PRTime gElapsedTime; // enable when we time it...
 static int gKeepRunning = 0;
 static bool gVerbose = false;
 static bool gAskUserForInput = false;
@@ -828,17 +830,19 @@ main(int argc, char* argv[])
     nsresult rv= (nsresult)-1;
     if (argc < 2) {
         printf("usage: %s [-verbose] [-file <name>] [-resume <startoffset>"
                "[-entityid <entityid>]] [-proxy <proxy>] [-pac <pacURL>]"
                "[-console] <url> <url> ... \n", argv[0]);
         return -1;
     }
 
+#if defined(PR_LOGGING)
     gTestLog = PR_NewLogModule("Test");
+#endif
 
     /* 
       The following code only deals with XPCOM registration stuff. and setting
       up the event queues. Copied from TestSocketIO.cpp
     */
 
     rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
     if (NS_FAILED(rv)) return -1;
--- a/netwerk/test/TestServ.cpp
+++ b/netwerk/test/TestServ.cpp
@@ -8,20 +8,22 @@
 #include "nsIServiceManager.h"
 #include "nsIServerSocket.h"
 #include "nsISocketTransport.h"
 #include "nsNetUtil.h"
 #include "nsStringAPI.h"
 #include "nsCOMPtr.h"
 #include "prlog.h"
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 class MySocketListener : public nsIServerSocketListener
 {
 protected:
     virtual ~MySocketListener() {}
 
 public:
@@ -112,17 +114,19 @@ main(int argc, char* argv[])
         return -1;
 
     nsresult rv= (nsresult)-1;
     if (argc < 2) {
         printf("usage: %s <port>\n", argv[0]);
         return -1;
     }
 
+#if defined(PR_LOGGING)
     gTestLog = PR_NewLogModule("Test");
+#endif
 
     /* 
      * The following code only deals with XPCOM registration stuff. and setting
      * up the event queues. Copied from TestSocketIO.cpp
      */
 
     rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
     if (NS_FAILED(rv)) return -1;
--- a/netwerk/test/TestSocketIO.cpp
+++ b/netwerk/test/TestSocketIO.cpp
@@ -20,18 +20,22 @@
 #include "nsIStreamListener.h"
 #include "nsIPipe.h"
 #include "nsIOutputStream.h"
 #include "nsIInputStream.h"
 #include "nsCRT.h"
 #include "nsCOMPtr.h"
 #include "nsIByteArrayInputStream.h"
 
+#if defined(PR_LOGGING)
 static PRLogModuleInfo *gTestSocketIOLog;
 #define LOG(args) PR_LOG(gTestSocketIOLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
 static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
 
 static PRTime gElapsedTime;
 static int gKeepRunning = 1;
 static nsIEventQueue* gEventQ = nullptr;
 
@@ -218,17 +222,19 @@ usage(char **argv)
 
 int
 main(int argc, char* argv[])
 {
     nsresult rv;
 
     signal(SIGSEGV, sighandler);
 
+#if defined(PR_LOGGING)
     gTestSocketIOLog = PR_NewLogModule("TestSocketIO");
+#endif
 
     if (argc < 3)
         usage(argv);
 
     int i=0;
     bool sync = false;
     if (nsCRT::strcasecmp(argv[1], "-sync") == 0) {
         if (argc < 4)
--- a/netwerk/test/TestSocketTransport.cpp
+++ b/netwerk/test/TestSocketTransport.cpp
@@ -22,20 +22,22 @@
 #include "nsIStreamListener.h"
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 #include "nsAutoLock.h"
 #include "prlog.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -216,17 +218,19 @@ main(int argc, char* argv[])
     {
         nsCOMPtr<nsIServiceManager> servMan;
         NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
         nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
         NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
         if (registrar)
             registrar->AutoRegister(nullptr);
 
+#if defined(PR_LOGGING)
         gTestLog = PR_NewLogModule("Test");
+#endif
 
         // Make sure the DNS service is initialized on the main thread
         nsCOMPtr<nsIDNSService> dns =
                  do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
         if (NS_FAILED(rv)) return rv;
 
         nsCOMPtr<nsPISocketTransportService> sts =
             do_GetService(kSocketTransportServiceCID, &rv);
--- a/netwerk/test/TestStreamChannel.cpp
+++ b/netwerk/test/TestStreamChannel.cpp
@@ -20,21 +20,25 @@
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 #include "nsAutoLock.h"
 #include "prlog.h"
 #include <algorithm>
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 
 static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class MyListener : public nsIStreamListener
@@ -175,17 +179,19 @@ main(int argc, char* argv[])
     {
         nsCOMPtr<nsIServiceManager> servMan;
         NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
         nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
         NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
         if (registrar)
             registrar->AutoRegister(nullptr);
 
+#if defined(PR_LOGGING)
         gTestLog = PR_NewLogModule("Test");
+#endif
 
         nsCOMPtr<nsIFile> file;
         rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file));
         if (NS_FAILED(rv)) return rv;
 
         rv = RunTest(file);
         NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
 
--- a/netwerk/test/TestStreamLoader.cpp
+++ b/netwerk/test/TestStreamLoader.cpp
@@ -1,20 +1,22 @@
 #include <stdio.h>
 #include "TestCommon.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
 #include "prlog.h"
 #include "mozilla/Attributes.h"
 #include "nsIScriptSecurityManager.h"
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 class MyStreamLoaderObserver final : public nsIStreamLoaderObserver
 {
   ~MyStreamLoaderObserver() {}
 
 public:
   NS_DECL_ISUPPORTS
@@ -45,17 +47,19 @@ int main(int argc, char **argv)
   if (test_common_init(&argc, &argv) != 0)
     return -1;
 
   if (argc < 2) {
     printf("usage: %s <url>\n", argv[0]);
     return -1;
   }
 
+#if defined(PR_LOGGING)
   gTestLog = PR_NewLogModule("Test");
+#endif
 
   nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
   if (NS_FAILED(rv))
     return -1;
 
   {
     nsCOMPtr<nsIURI> uri;
     rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(argv[1]));
--- a/netwerk/test/TestStreamPump.cpp
+++ b/netwerk/test/TestStreamPump.cpp
@@ -22,21 +22,25 @@
 #include "nsNetUtil.h"
 #include "nsAutoLock.h"
 #include "prlog.h"
 #include "prprf.h"
 #include <algorithm>
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
+#else
+#define LOG(args)
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class MyListener : public nsIStreamListener
 {
 public:
     NS_DECL_ISUPPORTS
 
@@ -146,17 +150,19 @@ main(int argc, char* argv[])
     {
         nsCOMPtr<nsIServiceManager> servMan;
         NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
         nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
         NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
         if (registrar)
             registrar->AutoRegister(nullptr);
 
+#if defined(PR_LOGGING)
         gTestLog = PR_NewLogModule("Test");
+#endif
 
         nsCOMPtr<nsIFile> file;
         rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file));
         if (NS_FAILED(rv)) return rv;
 
         rv = RunTest(file, offset, length);
         NS_ASSERTION(NS_SUCCEEDED(rv), "RunTest failed");
 
--- a/netwerk/test/TestStreamTransport.cpp
+++ b/netwerk/test/TestStreamTransport.cpp
@@ -20,20 +20,22 @@
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 #include "nsAutoLock.h"
 #include "prlog.h"
 #include "prenv.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 ////////////////////////////////////////////////////////////////////////////////
 
 static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID);
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -273,17 +275,19 @@ main(int argc, char* argv[])
     {
         nsCOMPtr<nsIServiceManager> servMan;
         NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
         nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
         NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
         if (registrar)
             registrar->AutoRegister(nullptr);
 
+#if defined(PR_LOGGING)
         gTestLog = PR_NewLogModule("Test");
+#endif
 
         nsCOMPtr<nsIFile> srcFile;
         rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(srcFile));
         if (NS_FAILED(rv)) return rv;
 
         nsCOMPtr<nsIFile> destFile;
         rv = srcFile->Clone(getter_AddRefs(destFile));
         if (NS_FAILED(rv)) return rv;
--- a/netwerk/test/TestUpload.cpp
+++ b/netwerk/test/TestUpload.cpp
@@ -11,20 +11,22 @@
 
 #include "nsIComponentRegistrar.h"
 #include "nsIServiceManager.h"
 #include "nsNetUtil.h"
 
 #include "nsIUploadChannel.h"
 
 #include "prlog.h"
+#if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=Test:5
 //
 static PRLogModuleInfo *gTestLog = nullptr;
+#endif
 #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args)
 
 //-----------------------------------------------------------------------------
 // InputTestConsumer
 //-----------------------------------------------------------------------------
 
 class InputTestConsumer : public nsIStreamListener
 {
@@ -103,17 +105,19 @@ main(int argc, char* argv[])
 
     if (argc < 2) {
         printf("usage: %s <url> <file-to-upload>\n", argv[0]);
         return -1;
     }
     char* uriSpec  = argv[1];
     char* fileName = argv[2];
 
+#if defined(PR_LOGGING) 
     gTestLog = PR_NewLogModule("Test");
+#endif
 
     {
         nsCOMPtr<nsIServiceManager> servMan;
         NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
 
         // first thing to do is create ourselves a stream that
         // is to be uploaded.
         nsCOMPtr<nsIInputStream> uploadStream;
--- a/netwerk/wifi/nsWifiAccessPoint.cpp
+++ b/netwerk/wifi/nsWifiAccessPoint.cpp
@@ -2,17 +2,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWifiAccessPoint.h"
 #include "nsString.h"
 #include "nsMemory.h"
 #include "prlog.h"
 
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo *gWifiMonitorLog;
+#endif
 #define LOG(args)     PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
 
 
 NS_IMPL_ISUPPORTS(nsWifiAccessPoint, nsIWifiAccessPoint)
 
 nsWifiAccessPoint::nsWifiAccessPoint()
 {
   // make sure these are null terminated (because we are paranoid)
--- a/netwerk/wifi/nsWifiMonitor.cpp
+++ b/netwerk/wifi/nsWifiMonitor.cpp
@@ -15,29 +15,33 @@
 #include "nsWifiAccessPoint.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Services.h"
 
 using namespace mozilla;
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo *gWifiMonitorLog;
+#endif
 
 NS_IMPL_ISUPPORTS(nsWifiMonitor,
                   nsIRunnable,
                   nsIObserver,
                   nsIWifiMonitor)
 
 nsWifiMonitor::nsWifiMonitor()
 : mKeepGoing(true)
 , mThreadComplete(false)
 , mReentrantMonitor("nsWifiMonitor.mReentrantMonitor")
 {
+#if defined(PR_LOGGING)
   gWifiMonitorLog = PR_NewLogModule("WifiMonitor");
+#endif
 
   nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
   if (obsSvc)
     obsSvc->AddObserver(this, "xpcom-shutdown", false);
 
   LOG(("@@@@@ wifimonitor created\n"));
 }
 
--- a/netwerk/wifi/nsWifiMonitor.h
+++ b/netwerk/wifi/nsWifiMonitor.h
@@ -21,17 +21,19 @@
 #include "nsITimer.h"
 #include "mozilla/Attributes.h"
 #include "nsIInterfaceRequestor.h"
 
 #ifdef XP_WIN
 #include "win_wifiScanner.h"
 #endif
 
+#if defined(PR_LOGGING)
 extern PRLogModuleInfo *gWifiMonitorLog;
+#endif
 #define LOG(args)     PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args)
 
 class nsWifiAccessPoint;
 
 #define kDefaultWifiScanInterval 5 /* seconds */
 
 class nsWifiListener
 {
--- a/netwerk/wifi/nsWifiMonitorGonk.cpp
+++ b/netwerk/wifi/nsWifiMonitorGonk.cpp
@@ -17,26 +17,30 @@
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Services.h"
 
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 
 using namespace mozilla;
 
+#if defined(PR_LOGGING)
 PRLogModuleInfo *gWifiMonitorLog;
+#endif
 
 NS_IMPL_ISUPPORTS(nsWifiMonitor,
                   nsIWifiMonitor,
                   nsIObserver,
                   nsIWifiScanResultsReady)
 
 nsWifiMonitor::nsWifiMonitor()
 {
+#if defined(PR_LOGGING)
   gWifiMonitorLog = PR_NewLogModule("WifiMonitor");
+#endif
 
   nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
   if (obsSvc) {
     obsSvc->AddObserver(this, "xpcom-shutdown", false);
   }
   LOG(("@@@@@ wifimonitor created\n"));
 }