Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in various files.r=benjamin
authorsajitk <sajitk@rocketmail.com>
Thu, 28 Jan 2016 10:35:00 -0800
changeset 288367 df2083106d8d69bcb8112ab95efe814103947ad9
parent 288366 4123969ee94c0ab32f831d39d44543fcd983c3c8
child 288368 5c19306be55e240d32c7b36f39a06b640c69fce5
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs1219482
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in various files.r=benjamin
docshell/base/nsDocShell.cpp
docshell/shistory/nsSHistory.cpp
extensions/auth/nsAuth.h
extensions/auth/nsAuthFactory.cpp
extensions/gio/nsGIOProtocolHandler.cpp
extensions/pref/autoconfig/src/nsAutoConfig.cpp
extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
extensions/pref/autoconfig/src/nsReadConfig.cpp
hal/Hal.cpp
hal/HalLog.h
ipc/chromium/src/base/logging.cc
ipc/chromium/src/base/logging.h
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/src/XPCLog.cpp
js/xpconnect/src/nsXPConnect.cpp
modules/libjar/nsJARChannel.cpp
parser/htmlparser/nsExpatDriver.cpp
rdf/base/nsCompositeDataSource.cpp
rdf/base/nsInMemoryDataSource.cpp
rdf/base/nsRDFContentSink.cpp
rdf/base/nsRDFService.cpp
rdf/base/nsRDFXMLDataSource.cpp
storage/VacuumManager.cpp
storage/mozStorageAsyncStatement.cpp
storage/mozStorageConnection.cpp
storage/mozStoragePrivateHelpers.cpp
storage/mozStorageStatement.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -261,19 +261,19 @@ static uint32_t gValidateOrigin = 0xffff
 
 // Hint for native dispatch of events on how long to delay after
 // all documents have loaded in milliseconds before favoring normal
 // native event dispatch priorites over performance
 // Can be overridden with docshell.event_starvation_delay_hint pref.
 #define NS_EVENT_STARVATION_DELAY_HINT 2000
 
 #ifdef DEBUG
-static PRLogModuleInfo* gDocShellLog;
+static mozilla::LazyLogModule gDocShellLog("nsDocShell");
 #endif
-static PRLogModuleInfo* gDocShellLeakLog;
+static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak");;
 
 const char kBrandBundleURL[]      = "chrome://branding/locale/brand.properties";
 const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties";
 
 static void
 FavorPerformanceHint(bool aPerfOverStarvation)
 {
   nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
@@ -812,27 +812,17 @@ nsDocShell::nsDocShell()
   mHistoryID = ++gDocshellIDCounter;
   if (gDocShellCount++ == 0) {
     NS_ASSERTION(sURIFixup == nullptr,
                  "Huh, sURIFixup not null in first nsDocShell ctor!");
 
     CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup);
   }
 
-#ifdef DEBUG
-  if (!gDocShellLog) {
-    gDocShellLog = PR_NewLogModule("nsDocShell");
-  }
-#endif
-  if (!gDocShellLeakLog) {
-    gDocShellLeakLog = PR_NewLogModule("nsDocShellLeak");
-  }
-  if (gDocShellLeakLog) {
-    MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this));
-  }
+  MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this));
 
 #ifdef DEBUG
   // We're counting the number of |nsDocShells| to help find leaks
   ++gNumberOfDocShells;
   if (!PR_GetEnv("MOZ_QUIET")) {
     printf_stderr("++DOCSHELL %p == %ld [pid = %d] [id = %llu]\n",
                   (void*)this,
                   gNumberOfDocShells,
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -54,36 +54,29 @@ static PRCList gSHistoryList;
 // Max viewers allowed total, across all SHistory objects - negative default
 // means we will calculate how many viewers to cache based on total memory
 int32_t nsSHistory::sHistoryMaxTotalViewers = -1;
 
 // A counter that is used to be able to know the order in which
 // entries were touched, so that we can evict older entries first.
 static uint32_t gTouchCounter = 0;
 
-static PRLogModuleInfo*
-GetSHistoryLog()
-{
-  static PRLogModuleInfo* sLog;
-  if (!sLog) {
-    sLog = PR_NewLogModule("nsSHistory");
-  }
-  return sLog;
-}
-#define LOG(format) MOZ_LOG(GetSHistoryLog(), mozilla::LogLevel::Debug, format)
+static LazyLogModule gSHistoryLog("nsSHistory");
+
+#define LOG(format) MOZ_LOG(gSHistoryLog, mozilla::LogLevel::Debug, format)
 
 // This macro makes it easier to print a log message which includes a URI's
 // spec.  Example use:
 //
 //  nsIURI *uri = [...];
 //  LOG_SPEC(("The URI is %s.", _spec), uri);
 //
 #define LOG_SPEC(format, uri)                              \
   PR_BEGIN_MACRO                                           \
-    if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) {     \
+    if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) {     \
       nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)"));\
       if (uri) {                                           \
         uri->GetSpec(_specStr);                            \
       }                                                    \
       const char* _spec = _specStr.get();                  \
       LOG(format);                                         \
     }                                                      \
   PR_END_MACRO
@@ -91,17 +84,17 @@ GetSHistoryLog()
 // This macro makes it easy to log a message including an SHEntry's URI.
 // For example:
 //
 //  nsCOMPtr<nsISHEntry> shentry = [...];
 //  LOG_SHENTRY_SPEC(("shentry %p has uri %s.", shentry.get(), _spec), shentry);
 //
 #define LOG_SHENTRY_SPEC(format, shentry)                  \
   PR_BEGIN_MACRO                                           \
-    if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) {     \
+    if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) {     \
       nsCOMPtr<nsIURI> uri;                                \
       shentry->GetURI(getter_AddRefs(uri));                \
       LOG_SPEC(format, uri);                               \
     }                                                      \
   PR_END_MACRO
 
 // Iterates over all registered session history listeners.
 #define ITERATE_LISTENERS(body)                            \
--- a/extensions/auth/nsAuth.h
+++ b/extensions/auth/nsAuth.h
@@ -15,13 +15,13 @@ enum pType {
 #include "mozilla/Logging.h"
 
 //
 // in order to do logging, the following environment variables need to be set:
 // 
 //      set NSPR_LOG_MODULES=negotiateauth:4
 //      set NSPR_LOG_FILE=negotiateauth.log
 //
-extern PRLogModuleInfo* gNegotiateLog;
+extern mozilla::LazyLogModule gNegotiateLog;
 
 #define LOG(args) MOZ_LOG(gNegotiateLog, mozilla::LogLevel::Debug, args)
 
 #endif /* !defined( nsAuth_h__ ) */
--- a/extensions/auth/nsAuthFactory.cpp
+++ b/extensions/auth/nsAuthFactory.cpp
@@ -215,23 +215,22 @@ static const mozilla::Module::ContractID
   { NS_AUTH_MODULE_CONTRACTID_PREFIX "sys-ntlm", &kNS_SAMBANTLMAUTH_CID },
 #endif
   { NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "negotiate", &kNS_HTTPNEGOTIATEAUTH_CID },
   { NS_AUTH_MODULE_CONTRACTID_PREFIX "sasl-gssapi", &kNS_AUTHSASL_CID },
   { nullptr }
 };
 
 //-----------------------------------------------------------------------------
-PRLogModuleInfo *gNegotiateLog;
+mozilla::LazyLogModule gNegotiateLog("negotiateauth");
 
 // setup nspr logging ...
 static nsresult
 InitNegotiateAuth()
 {
-  gNegotiateLog = PR_NewLogModule("negotiateauth");
   return NS_OK;
 }
 
 static void
 DestroyNegotiateAuth()
 {
   nsAuthGSSAPI::Shutdown();
 }
--- a/extensions/gio/nsGIOProtocolHandler.cpp
+++ b/extensions/gio/nsGIOProtocolHandler.cpp
@@ -32,17 +32,17 @@
 #include <algorithm>
 
 #define MOZ_GIO_SCHEME              "moz-gio"
 #define MOZ_GIO_SUPPORTED_PROTOCOLS "network.gio.supported-protocols"
 
 //-----------------------------------------------------------------------------
 
 // NSPR_LOG_MODULES=gio:5
-static PRLogModuleInfo *sGIOLog;
+static mozilla::LazyLogModule sGIOLog("gio");
 #define LOG(args) MOZ_LOG(sGIOLog, mozilla::LogLevel::Debug, args)
 
 
 //-----------------------------------------------------------------------------
 static nsresult
 MapGIOResult(gint code) 
 {
   switch (code)
@@ -901,18 +901,16 @@ class nsGIOProtocolHandler final : publi
     nsCString mSupportedProtocols;
 };
 
 NS_IMPL_ISUPPORTS(nsGIOProtocolHandler, nsIProtocolHandler, nsIObserver)
 
 nsresult
 nsGIOProtocolHandler::Init()
 {
-  sGIOLog = PR_NewLogModule("gio");
-
   nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (prefs)
   {
     InitSupportedProtocolsPref(prefs);
     prefs->AddObserver(MOZ_GIO_SUPPORTED_PROTOCOLS, this, false);
   }
 
   return NS_OK;
--- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp
@@ -21,17 +21,17 @@
 #include "nsNetUtil.h"
 #include "nspr.h"
 #include <algorithm>
 
 #include "mozilla/Logging.h"
 
 using mozilla::LogLevel;
 
-PRLogModuleInfo *MCD;
+mozilla::LazyLogModule MCD("MCD");
 
 extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
                                           const char *filename, 
                                           bool bGlobalContext, 
                                           bool bCallbacks, 
                                           bool skipFirstLine);
 
 // nsISupports Implementation
--- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
+++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
@@ -14,17 +14,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/Maybe.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsJSPrincipals.h"
 #include "nsIScriptError.h"
 #include "jswrapper.h"
 
-extern PRLogModuleInfo *MCD;
+extern mozilla::LazyLogModule MCD;
 using mozilla::AutoSafeJSContext;
 
 //*****************************************************************************
 
 static JS::PersistentRooted<JSObject *> autoconfigSb;
 
 nsresult CentralizedAdminPrefManagerInit()
 {
--- a/extensions/pref/autoconfig/src/nsReadConfig.cpp
+++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp
@@ -21,17 +21,17 @@
 #include "nsNetUtil.h"
 #include "prmem.h"
 #include "nsString.h"
 #include "nsCRT.h"
 #include "nspr.h"
 #include "nsXULAppAPI.h"
 #include "nsContentUtils.h"
 
-extern PRLogModuleInfo *MCD;
+extern mozilla::LazyLogModule MCD;
 
 extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
                                           const char *filename, 
                                           bool bGlobalContext, 
                                           bool bCallbacks, 
                                           bool skipFirstLine);
 extern nsresult CentralizedAdminPrefManagerInit();
 extern nsresult CentralizedAdminPrefManagerFinish();
@@ -70,18 +70,16 @@ static void DisplayError(void)
 
 // nsISupports Implementation
 
 NS_IMPL_ISUPPORTS(nsReadConfig, nsIReadConfig, nsIObserver)
 
 nsReadConfig::nsReadConfig() :
     mRead(false)
 {
-    if (!MCD)
-      MCD = PR_NewLogModule("MCD");
 }
 
 nsresult nsReadConfig::Init()
 {
     nsresult rv;
     
     nsCOMPtr<nsIObserverService> observerService = 
         do_GetService("@mozilla.org/observer-service;1", &rv);
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -57,23 +57,20 @@ using namespace mozilla::dom;
     } else {                                      \
       return hal_impl::_call;                     \
     }                                             \
   } while (0)
 
 namespace mozilla {
 namespace hal {
 
-PRLogModuleInfo *
+mozilla::LogModule *
 GetHalLog()
 {
-  static PRLogModuleInfo *sHalLog;
-  if (!sHalLog) {
-    sHalLog = PR_NewLogModule("hal");
-  }
+  static mozilla::LazyLogModule sHalLog("hal");
   return sHalLog;
 }
 
 namespace {
 
 void
 AssertMainThread()
 {
--- a/hal/HalLog.h
+++ b/hal/HalLog.h
@@ -15,17 +15,17 @@
  * This should be considered a private include and not used in non-HAL code.
  * To enable logging in non-debug builds define the PR_FORCE_LOG macro here.
  */
 
 namespace mozilla {
 
 namespace hal {
 
-extern PRLogModuleInfo *GetHalLog();
+mozilla::LogModule *GetHalLog();
 #define HAL_LOG(...) \
   MOZ_LOG(mozilla::hal::GetHalLog(), LogLevel::Debug, (__VA_ARGS__))
 #define HAL_ERR(...) \
   MOZ_LOG(mozilla::hal::GetHalLog(), LogLevel::Error, (__VA_ARGS__))
 
 } // namespace hal
 
 } // namespace mozilla
--- a/ipc/chromium/src/base/logging.cc
+++ b/ipc/chromium/src/base/logging.cc
@@ -37,41 +37,33 @@ Logger::~Logger()
     break;
 
   case LOG_FATAL:
     prlevel = LogLevel::Error;
     xpcomlevel = NS_DEBUG_ABORT;
     break;
   }
 
-  MOZ_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
+  MOZ_LOG(gChromiumPRLog, prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
   if (xpcomlevel != -1)
     NS_DebugBreak(xpcomlevel, mMsg, NULL, mFile, mLine);
 
   PR_Free(mMsg);
 }
 
 void
 Logger::printf(const char* fmt, ...)
 {
   va_list args;
   va_start(args, fmt);
   mMsg = PR_vsprintf_append(mMsg, fmt, args);
   va_end(args);
 }
 
-PRLogModuleInfo* Logger::gChromiumPRLog;
-
-PRLogModuleInfo* Logger::GetLog()
-{
-  if (!gChromiumPRLog)
-    gChromiumPRLog = PR_NewLogModule("chromium");
-  return gChromiumPRLog;
-}
-
+LazyLogModule Logger::gChromiumPRLog("chromium");
 } // namespace mozilla 
 
 mozilla::Logger&
 operator<<(mozilla::Logger& log, const char* s)
 {
   log.printf("%s", s);
   return log;
 }
--- a/ipc/chromium/src/base/logging.h
+++ b/ipc/chromium/src/base/logging.h
@@ -40,18 +40,18 @@ public:
   { }
 
   ~Logger();
 
   // not private so that the operator<< overloads can get to it
   void printf(const char* fmt, ...);
 
 private:
-  static PRLogModuleInfo* gChromiumPRLog;
-  static PRLogModuleInfo* GetLog();
+  static mozilla::LazyLogModule gChromiumPRLog;
+//  static PRLogModuleInfo* GetLog();
 
   LogSeverity mSeverity;
   const char* mFile;
   int mLine;
   char* mMsg;
 
   DISALLOW_EVIL_CONSTRUCTORS(Logger);
 };
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -67,17 +67,17 @@ static const char kJSCachePrefix[] = "js
 /**
  * Buffer sizes for serialization and deserialization of scripts.
  * FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008
  */
 #define XPC_SERIALIZATION_BUFFER_SIZE   (64 * 1024)
 #define XPC_DESERIALIZATION_BUFFER_SIZE (12 * 8192)
 
 // NSPR_LOG_MODULES=JSComponentLoader:5
-static PRLogModuleInfo* gJSCLLog;
+static LazyLogModule gJSCLLog("JSComponentLoader");
 
 #define LOG(args) MOZ_LOG(gJSCLLog, mozilla::LogLevel::Debug, args)
 
 // Components.utils.import error messages
 #define ERROR_SCOPE_OBJ "%s - Second argument must be an object."
 #define ERROR_NOT_PRESENT "%s - EXPORTED_SYMBOLS is not present."
 #define ERROR_NOT_AN_ARRAY "%s - EXPORTED_SYMBOLS is not an array."
 #define ERROR_GETTING_ARRAY_LENGTH "%s - Error getting array length of EXPORTED_SYMBOLS."
@@ -194,20 +194,16 @@ mozJSComponentLoader::mozJSComponentLoad
     : mModules(16),
       mImports(16),
       mInProgressImports(16),
       mInitialized(false),
       mReuseLoaderGlobal(false)
 {
     MOZ_ASSERT(!sSelf, "mozJSComponentLoader should be a singleton");
 
-    if (!gJSCLLog) {
-        gJSCLLog = PR_NewLogModule("JSComponentLoader");
-    }
-
     sSelf = this;
 }
 
 #define ENSURE_DEP(name) { nsresult rv = Ensure##name(); NS_ENSURE_SUCCESS(rv, rv); }
 #define ENSURE_DEPS(...) MOZ_FOR_EACH(ENSURE_DEP, (), (__VA_ARGS__));
 #define BEGIN_ENSURE(self, ...) { \
     if (m##self) \
         return NS_OK; \
--- a/js/xpconnect/src/XPCLog.cpp
+++ b/js/xpconnect/src/XPCLog.cpp
@@ -20,40 +20,37 @@
 #define LINE_LEN        200
 #define INDENT_FACTOR   2
 
 #define CAN_RUN (g_InitState == 1 || (g_InitState == 0 && Init()))
 
 static char*    g_Spaces;
 static int      g_InitState = 0;
 static int      g_Indent = 0;
-static PRLogModuleInfo* g_LogMod = nullptr;
+static mozilla::LazyLogModule g_LogMod("xpclog");
 
 static bool Init()
 {
-    g_LogMod = PR_NewLogModule("xpclog");
     g_Spaces = new char[SPACE_COUNT+1];
-    if (!g_LogMod || !g_Spaces || !MOZ_LOG_TEST(g_LogMod,LogLevel::Error)) {
+    if (!g_Spaces || !MOZ_LOG_TEST(g_LogMod,LogLevel::Error)) {
         g_InitState = 1;
         XPC_Log_Finish();
         return false;
     }
     memset(g_Spaces, ' ', SPACE_COUNT);
     g_Spaces[SPACE_COUNT] = 0;
     g_InitState = 1;
     return true;
 }
 
 void
 XPC_Log_Finish()
 {
     if (g_InitState == 1) {
         delete [] g_Spaces;
-        // we'd like to properly cleanup the LogModule, but nspr owns that
-        g_LogMod = nullptr;
     }
     g_InitState = -1;
 }
 
 void
 XPC_Log_print(const char* fmt, ...)
 {
     va_list ap;
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -192,17 +192,17 @@ xpc::ErrorReport::Init(JSErrorReport* aR
     mSourceLine.Assign(aReport->linebuf(), aReport->linebufLength());
 
     mLineNumber = aReport->lineno;
     mColumn = aReport->column;
     mFlags = aReport->flags;
     mIsMuted = aReport->isMuted;
 }
 
-static PRLogModuleInfo* gJSDiagnostics;
+static LazyLogModule gJSDiagnostics("JSDiagnostics");
 
 void
 xpc::ErrorReport::LogToConsole()
 {
   LogToConsoleWithStack(nullptr);
 }
 void
 xpc::ErrorReport::LogToConsoleWithStack(JS::HandleObject aStack)
@@ -222,25 +222,20 @@ xpc::ErrorReport::LogToConsoleWithStack(
         error.AppendInt(mLineNumber, 10);
         error.AppendLiteral(": ");
         error.Append(NS_LossyConvertUTF16toASCII(mErrorMsg));
 
         fprintf(stderr, "%s\n", error.get());
         fflush(stderr);
     }
 
-    // Log to the PR Log Module.
-    if (!gJSDiagnostics)
-        gJSDiagnostics = PR_NewLogModule("JSDiagnostics");
-    if (gJSDiagnostics) {
-        MOZ_LOG(gJSDiagnostics,
-                JSREPORT_IS_WARNING(mFlags) ? LogLevel::Warning : LogLevel::Error,
-                ("file %s, line %u\n%s", NS_LossyConvertUTF16toASCII(mFileName).get(),
-                 mLineNumber, NS_LossyConvertUTF16toASCII(mErrorMsg).get()));
-    }
+    MOZ_LOG(gJSDiagnostics,
+            JSREPORT_IS_WARNING(mFlags) ? LogLevel::Warning : LogLevel::Error,
+            ("file %s, line %u\n%s", NS_LossyConvertUTF16toASCII(mFileName).get(),
+             mLineNumber, NS_LossyConvertUTF16toASCII(mErrorMsg).get()));
 
     // Log to the console. We do this last so that we can simply return if
     // there's no console service without affecting the other reporting
     // mechanisms.
     nsCOMPtr<nsIConsoleService> consoleService =
       do_GetService(NS_CONSOLESERVICE_CONTRACTID);
 
     nsCOMPtr<nsIScriptError> errorObject;
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -43,17 +43,17 @@ static NS_DEFINE_CID(kZipReaderCID, NS_Z
 // own LOG macro below.)
 #ifdef LOG
 #undef LOG
 #endif
 
 //
 // set NSPR_LOG_MODULES=nsJarProtocol:5
 //
-static PRLogModuleInfo *gJarProtocolLog = nullptr;
+static LazyLogModule gJarProtocolLog("nsJarProtocol");
 
 #define LOG(args)     MOZ_LOG(gJarProtocolLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(gJarProtocolLog, mozilla::LogLevel::Debug)
 
 //-----------------------------------------------------------------------------
 // nsJARInputThunk
 //
 // this class allows us to do some extra work on the stream transport thread.
@@ -198,19 +198,16 @@ nsJARChannel::nsJARChannel()
     , mContentLength(-1)
     , mLoadFlags(LOAD_NORMAL)
     , mStatus(NS_OK)
     , mIsPending(false)
     , mIsUnsafe(true)
     , mOpeningRemote(false)
     , mBlockRemoteFiles(false)
 {
-    if (!gJarProtocolLog)
-        gJarProtocolLog = PR_NewLogModule("nsJarProtocol");
-
     mBlockRemoteFiles = Preferences::GetBool("network.jar.block-remote-files", false);
 
     // hold an owning reference to the jar handler
     NS_ADDREF(gJarHandler);
 }
 
 nsJARChannel::~nsJARChannel()
 {
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -34,24 +34,17 @@
 
 using mozilla::fallible;
 using mozilla::LogLevel;
 
 #define kExpatSeparatorChar 0xFFFF
 
 static const char16_t kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' };
 
-static PRLogModuleInfo *
-GetExpatDriverLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("expatdriver");
-  return sLog;
-}
+static mozilla::LazyLogModule gExpatDriverLog("expatdriver");
 
 /***************************** EXPAT CALL BACKS ******************************/
 // The callback handlers that get called from the expat parser.
 
 static void
 Driver_HandleXMLDeclaration(void *aUserData,
                             const XML_Char *aVersion,
                             const XML_Char *aEncoding,
@@ -1053,17 +1046,17 @@ nsExpatDriver::ConsumeToken(nsScanner& a
   nsScannerIterator start = currentExpatPosition;
   start.advance(mExpatBuffered);
 
   // This is the end of the last buffer (at this point, more data could come in
   // later).
   nsScannerIterator end;
   aScanner.EndReading(end);
 
-  MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug,
+  MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
          ("Remaining in expat's buffer: %i, remaining in scanner: %i.",
           mExpatBuffered, Distance(start, end)));
 
   // We want to call Expat if we have more buffers, or if we know there won't
   // be more buffers (and so we want to flush the remaining data), or if we're
   // currently blocked and there's data in Expat's buffer.
   while (start != end || (mIsFinalChunk && !mMadeFinalCallToExpat) ||
          (BlockedOrInterrupted() && mExpatBuffered > 0)) {
@@ -1074,37 +1067,37 @@ nsExpatDriver::ConsumeToken(nsScanner& a
     uint32_t length;
     if (blocked || noMoreBuffers) {
       // If we're blocked we just resume Expat so we don't need a buffer, if
       // there aren't any more buffers we pass a null buffer to Expat.
       buffer = nullptr;
       length = 0;
 
       if (blocked) {
-        MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug,
+        MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
                ("Resuming Expat, will parse data remaining in Expat's "
                 "buffer.\nContent of Expat's buffer:\n-----\n%s\n-----\n",
                 NS_ConvertUTF16toUTF8(currentExpatPosition.get(),
                                       mExpatBuffered).get()));
       }
       else {
         NS_ASSERTION(mExpatBuffered == Distance(currentExpatPosition, end),
                      "Didn't pass all the data to Expat?");
-        MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug,
+        MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
                ("Last call to Expat, will parse data remaining in Expat's "
                 "buffer.\nContent of Expat's buffer:\n-----\n%s\n-----\n",
                 NS_ConvertUTF16toUTF8(currentExpatPosition.get(),
                                       mExpatBuffered).get()));
       }
     }
     else {
       buffer = start.get();
       length = uint32_t(start.size_forward());
 
-      MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug,
+      MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
              ("Calling Expat, will parse data remaining in Expat's buffer and "
               "new data.\nContent of Expat's buffer:\n-----\n%s\n-----\nNew "
               "data:\n-----\n%s\n-----\n",
               NS_ConvertUTF16toUTF8(currentExpatPosition.get(),
                                     mExpatBuffered).get(),
               NS_ConvertUTF16toUTF8(start.get(), length).get()));
     }
 
@@ -1140,17 +1133,17 @@ nsExpatDriver::ConsumeToken(nsScanner& a
           return (mInternalState = NS_ERROR_OUT_OF_MEMORY);
         }
       }
     }
 
     mExpatBuffered += length - consumed;
 
     if (BlockedOrInterrupted()) {
-      MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug,
+      MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
              ("Blocked or interrupted parser (probably for loading linked "
               "stylesheets or scripts)."));
 
       aScanner.SetPosition(currentExpatPosition, true);
       aScanner.Mark();
 
       return mInternalState;
     }
@@ -1201,17 +1194,17 @@ nsExpatDriver::ConsumeToken(nsScanner& a
     // (e.g. if we spun the event loop in an inline script). Reload end now
     // to compensate.
     aScanner.EndReading(end);
   }
 
   aScanner.SetPosition(currentExpatPosition, true);
   aScanner.Mark();
 
-  MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug,
+  MOZ_LOG(gExpatDriverLog, LogLevel::Debug,
          ("Remaining in expat's buffer: %i, remaining in scanner: %i.",
           mExpatBuffered, Distance(currentExpatPosition, end)));
 
   return NS_SUCCEEDED(mInternalState) ? kEOF : NS_OK;
 }
 
 NS_IMETHODIMP
 nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
--- a/rdf/base/nsCompositeDataSource.cpp
+++ b/rdf/base/nsCompositeDataSource.cpp
@@ -40,17 +40,17 @@
 #include "rdf.h"
 #include "nsCycleCollectionParticipant.h"
 
 #include "nsEnumeratorUtils.h"
 
 #include "mozilla/Logging.h"
 #include "prprf.h"
 #include <stdio.h>
-PRLogModuleInfo* nsRDFLog = nullptr;
+mozilla::LazyLogModule nsRDFLog("RDF");
 
 //----------------------------------------------------------------------
 //
 // CompositeDataSourceImpl
 //
 
 class CompositeEnumeratorImpl;
 class CompositeArcsInOutEnumeratorImpl;
@@ -485,18 +485,16 @@ NS_NewRDFCompositeDataSource(nsIRDFCompo
 }
 
 
 CompositeDataSourceImpl::CompositeDataSourceImpl(void)
 	: mAllowNegativeAssertions(true),
 	  mCoalesceDuplicateArcs(true),
       mUpdateBatchNest(0)
 {
-    if (nsRDFLog == nullptr) 
-        nsRDFLog = PR_NewLogModule("RDF");
 }
 
 //----------------------------------------------------------------------
 //
 // nsISupports interface
 //
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(CompositeDataSourceImpl)
--- a/rdf/base/nsInMemoryDataSource.cpp
+++ b/rdf/base/nsInMemoryDataSource.cpp
@@ -347,20 +347,20 @@ public:
                  nsIRDFResource* asource,
                  nsIRDFResource* aProperty,
                  nsIRDFNode* aTarget,
                  bool aTruthValue = true);
 
     bool    mPropagateChanges;
 
 private:
-    static PRLogModuleInfo* gLog;
+    static mozilla::LazyLogModule gLog;
 };
 
-PRLogModuleInfo* InMemoryDataSource::gLog;
+mozilla::LazyLogModule InMemoryDataSource::gLog("InMemoryDataSource");
 
 //----------------------------------------------------------------------
 //
 // InMemoryAssertionEnumeratorImpl
 //
 
 /**
  * InMemoryAssertionEnumeratorImpl
@@ -738,19 +738,16 @@ InMemoryDataSource::InMemoryDataSource(n
     , mReverseArcs(PLDHashTable::StubOps(), sizeof(Entry))
     , mNumObservers(0)
     , mReadCount(0)
 {
     NS_INIT_AGGREGATED(aOuter);
 
     mPropagateChanges = true;
     MOZ_COUNT_CTOR(InMemoryDataSource);
-
-    if (! gLog)
-        gLog = PR_NewLogModule("InMemoryDataSource");
 }
 
 
 InMemoryDataSource::~InMemoryDataSource()
 {
 #ifdef DEBUG_REFS
     --gInstanceCount;
     fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount);
--- a/rdf/base/nsRDFContentSink.cpp
+++ b/rdf/base/nsRDFContentSink.cpp
@@ -221,30 +221,30 @@ protected:
         RDFContentSinkParseMode  mParseMode;
     };
 
     AutoTArray<RDFContextStackElement, 8>* mContextStack;
 
     nsCOMPtr<nsIURI> mDocumentURL;
 
 private:
-    static PRLogModuleInfo* gLog;
+    static mozilla::LazyLogModule gLog;
 };
 
 int32_t         RDFContentSinkImpl::gRefCnt = 0;
 nsIRDFService*  RDFContentSinkImpl::gRDFService;
 nsIRDFContainerUtils* RDFContentSinkImpl::gRDFContainerUtils;
 nsIRDFResource* RDFContentSinkImpl::kRDF_type;
 nsIRDFResource* RDFContentSinkImpl::kRDF_instanceOf;
 nsIRDFResource* RDFContentSinkImpl::kRDF_Alt;
 nsIRDFResource* RDFContentSinkImpl::kRDF_Bag;
 nsIRDFResource* RDFContentSinkImpl::kRDF_Seq;
 nsIRDFResource* RDFContentSinkImpl::kRDF_nextVal;
 
-PRLogModuleInfo* RDFContentSinkImpl::gLog;
+mozilla::LazyLogModule RDFContentSinkImpl::gLog("nsRDFContentSink");
 
 ////////////////////////////////////////////////////////////////////////
 
 #define RDF_ATOM(name_, value_) nsIAtom* RDFContentSinkImpl::name_;
 #include "nsRDFContentSinkAtomList.h"
 #undef RDF_ATOM
 
 #define RDF_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
@@ -285,19 +285,16 @@ RDFContentSinkImpl::RDFContentSinkImpl()
                                           &kRDF_nextVal);
         }
 
         NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
         rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
 
         NS_RegisterStaticAtoms(rdf_atoms);
     }
-
-    if (! gLog)
-        gLog = PR_NewLogModule("nsRDFContentSink");
 }
 
 
 RDFContentSinkImpl::~RDFContentSinkImpl()
 {
 #ifdef DEBUG_REFS
     --gInstanceCount;
     fprintf(stdout, "%d - RDF: RDFContentSinkImpl\n", gInstanceCount);
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -66,17 +66,17 @@ static NS_DEFINE_CID(kRDFXMLDataSourceCI
 static NS_DEFINE_CID(kRDFDefaultResourceCID,  NS_RDFDEFAULTRESOURCE_CID);
 
 static NS_DEFINE_IID(kIRDFLiteralIID,         NS_IRDFLITERAL_IID);
 static NS_DEFINE_IID(kIRDFDateIID,         NS_IRDFDATE_IID);
 static NS_DEFINE_IID(kIRDFIntIID,         NS_IRDFINT_IID);
 static NS_DEFINE_IID(kIRDFNodeIID,            NS_IRDFNODE_IID);
 static NS_DEFINE_IID(kISupportsIID,           NS_ISUPPORTS_IID);
 
-static PRLogModuleInfo* gLog = nullptr;
+static LazyLogModule gLog("nsRDFService");
 
 class BlobImpl;
 
 // These functions are copied from nsprpub/lib/ds/plhash.c, with one
 // change to free the key in DataSourceFreeEntry.
 // XXX sigh, why were DefaultAllocTable et. al. declared static, anyway?
 
 static void *
@@ -743,19 +743,16 @@ RDFServiceImpl::Init()
 
     if (! mNamedDataSources)
         return NS_ERROR_OUT_OF_MEMORY;
 
     mDefaultResourceFactory = do_GetClassObject(kRDFDefaultResourceCID, &rv);
     NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get default resource factory");
     if (NS_FAILED(rv)) return rv;
 
-    if (! gLog)
-        gLog = PR_NewLogModule("nsRDFService");
-
     return NS_OK;
 }
 
 
 RDFServiceImpl::~RDFServiceImpl()
 {
     if (mNamedDataSources) {
         PL_HashTableDestroy(mNamedDataSources);
--- a/rdf/base/nsRDFXMLDataSource.cpp
+++ b/rdf/base/nsRDFXMLDataSource.cpp
@@ -130,17 +130,17 @@ protected:
     nsCOMPtr<nsIURI>    mURL;
     nsCOMPtr<nsIStreamListener> mListener;
     nsNameSpaceMap      mNameSpaces;
 
     // pseudo-constants
     static int32_t gRefCnt;
     static nsIRDFService* gRDFService;
 
-    static PRLogModuleInfo* gLog;
+    static mozilla::LazyLogModule gLog;
 
     nsresult Init();
     RDFXMLDataSourceImpl(void);
     virtual ~RDFXMLDataSourceImpl(void);
     nsresult rdfXMLFlush(nsIURI *aURI);
 
     friend nsresult
     NS_NewRDFXMLDataSource(nsIRDFDataSource** aResult);
@@ -354,17 +354,17 @@ public:
 protected:
     nsresult
     BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer);
 };
 
 int32_t         RDFXMLDataSourceImpl::gRefCnt = 0;
 nsIRDFService*  RDFXMLDataSourceImpl::gRDFService;
 
-PRLogModuleInfo* RDFXMLDataSourceImpl::gLog;
+mozilla::LazyLogModule RDFXMLDataSourceImpl::gLog("nsRDFXMLDataSource");
 
 static const char kFileURIPrefix[] = "file:";
 static const char kResourceURIPrefix[] = "resource:";
 
 
 //----------------------------------------------------------------------
 
 nsresult
@@ -392,18 +392,16 @@ NS_NewRDFXMLDataSource(nsIRDFDataSource*
 }
 
 
 RDFXMLDataSourceImpl::RDFXMLDataSourceImpl(void)
     : mIsWritable(true),
       mIsDirty(false),
       mLoadState(eLoadState_Unloaded)
 {
-    if (! gLog)
-        gLog = PR_NewLogModule("nsRDFXMLDataSource");
 }
 
 
 nsresult
 RDFXMLDataSourceImpl::Init()
 {
     nsresult rv;
     NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
--- a/storage/VacuumManager.cpp
+++ b/storage/VacuumManager.cpp
@@ -34,17 +34,17 @@
 
 // This preferences root will contain last vacuum timestamps (in seconds) for
 // each database.  The database filename is used as a key.
 #define PREF_VACUUM_BRANCH "storage.vacuum.last."
 
 // Time between subsequent vacuum calls for a certain database.
 #define VACUUM_INTERVAL_SECONDS 30 * 86400 // 30 days.
 
-extern PRLogModuleInfo *gStorageLog;
+extern mozilla::LazyLogModule gStorageLog;
 
 namespace mozilla {
 namespace storage {
 
 namespace {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// BaseCallback
--- a/storage/mozStorageAsyncStatement.cpp
+++ b/storage/mozStorageAsyncStatement.cpp
@@ -22,17 +22,17 @@
 #include "mozStorageAsyncStatementParams.h"
 #include "mozStoragePrivateHelpers.h"
 #include "mozStorageStatementRow.h"
 #include "mozStorageStatement.h"
 #include "nsDOMClassInfo.h"
 
 #include "mozilla/Logging.h"
 
-extern PRLogModuleInfo *gStorageLog;
+extern mozilla::LazyLogModule gStorageLog;
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIClassInfo
 
 NS_IMPL_CI_INTERFACE_GETTER(AsyncStatement,
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -44,17 +44,17 @@
 #include "nsProxyRelease.h"
 #include <algorithm>
 
 #define MIN_AVAILABLE_BYTES_PER_CHUNKED_GROWTH 524288000 // 500 MiB
 
 // Maximum size of the pages cache per connection.
 #define MAX_CACHE_SIZE_KIBIBYTES 2048 // 2 MiB
 
-PRLogModuleInfo* gStorageLog = nullptr;
+mozilla::LazyLogModule gStorageLog("mozStorage");
 
 // Checks that the protected code is running on the main-thread only if the
 // connection was also opened on it.
 #ifdef DEBUG
 #define CHECK_MAINTHREAD_ABUSE() \
   do { \
     nsCOMPtr<nsIThread> mainThread = do_GetMainThread(); \
     NS_WARN_IF_FALSE(threadOpenedOn == mainThread || !NS_IsMainThread(), \
@@ -676,19 +676,16 @@ Connection::initializeInternal()
   if (mTelemetryFilename.IsEmpty()) {
     mTelemetryFilename = getFilename();
     MOZ_ASSERT(!mTelemetryFilename.IsEmpty());
   }
 
   // Properly wrap the database handle's mutex.
   sharedDBMutex.initWithMutex(sqlite3_db_mutex(mDBConn));
 
-  if (!gStorageLog)
-    gStorageLog = ::PR_NewLogModule("mozStorage");
-
   // SQLite tracing can slow down queries (especially long queries)
   // significantly. Don't trace unless the user is actively monitoring SQLite.
   if (MOZ_LOG_TEST(gStorageLog, LogLevel::Debug)) {
     ::sqlite3_trace(mDBConn, tracefunc, this);
 
     MOZ_LOG(gStorageLog, LogLevel::Debug, ("Opening connection to '%s' (%p)",
                                         mTelemetryFilename.get(), this));
   }
--- a/storage/mozStoragePrivateHelpers.cpp
+++ b/storage/mozStoragePrivateHelpers.cpp
@@ -19,17 +19,17 @@
 
 #include "Variant.h"
 #include "mozStoragePrivateHelpers.h"
 #include "mozIStorageStatement.h"
 #include "mozIStorageCompletionCallback.h"
 #include "mozIStorageBindingParams.h"
 
 #include "mozilla/Logging.h"
-extern PRLogModuleInfo* gStorageLog;
+extern mozilla::LazyLogModule gStorageLog;
 
 namespace mozilla {
 namespace storage {
 
 nsresult
 convertResultCode(int aSQLiteResultCode)
 {
   // Drop off the extended result bits of the result code.
--- a/storage/mozStorageStatement.cpp
+++ b/storage/mozStorageStatement.cpp
@@ -23,17 +23,17 @@
 #include "mozStorageStatementRow.h"
 #include "mozStorageStatement.h"
 #include "GeckoProfiler.h"
 #include "nsDOMClassInfo.h"
 
 #include "mozilla/Logging.h"
 
 
-extern PRLogModuleInfo* gStorageLog;
+extern mozilla::LazyLogModule gStorageLog;
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIClassInfo
 
 NS_IMPL_CI_INTERFACE_GETTER(Statement,