Bug 1219478: Replace PRLogModuleInfo usage with LazyLogModule in dom folders except media.r=amerchesini
authorsajitk <sajitk@rocketmail.com>
Mon, 23 Nov 2015 11:09:25 -0800
changeset 273866 c728b4bd9be62afcfda73eba03edc3bd07aee33f
parent 273865 0c34cc2dc429d2ea06415dc977def64d1a7ac72a
child 273867 be19277b423fb7940380282e3f1877073c23762a
push id29715
push userkwierso@gmail.com
push dateTue, 24 Nov 2015 21:54:25 +0000
treeherdermozilla-central@d9243e369c22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersamerchesini
bugs1219478
milestone45.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 1219478: Replace PRLogModuleInfo usage with LazyLogModule in dom folders except media.r=amerchesini
dom/base/ThirdPartyUtil.cpp
dom/base/nsContentPolicy.cpp
dom/base/nsContentSink.cpp
dom/base/nsContentSink.h
dom/base/nsDocument.cpp
dom/base/nsFocusManager.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsNodeInfoManager.cpp
dom/base/nsObjectLoadingContent.cpp
dom/base/nsScriptLoader.cpp
dom/base/nsStyleLinkElement.cpp
dom/camera/CameraCommon.h
dom/camera/DOMCameraManager.cpp
dom/events/IMEContentObserver.cpp
dom/events/IMEStateManager.cpp
dom/html/HTMLMediaElement.cpp
dom/html/HTMLTrackElement.cpp
dom/indexedDB/IndexedDatabaseManager.cpp
dom/indexedDB/IndexedDatabaseManager.h
dom/indexedDB/ProfilerHelpers.h
dom/ipc/ProcessPriorityManager.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginLogging.h
dom/plugins/ipc/PluginMessageUtils.cpp
dom/plugins/ipc/PluginMessageUtils.h
dom/security/SRICheck.cpp
dom/security/SRIMetadata.cpp
dom/security/nsCSPContext.cpp
dom/security/nsCSPParser.cpp
dom/security/nsCSPService.cpp
dom/security/nsCSPUtils.cpp
dom/system/gonk/mozstumbler/StumblerLogging.cpp
dom/system/gonk/mozstumbler/StumblerLogging.h
dom/xslt/base/txLog.h
dom/xul/XULDocument.cpp
dom/xul/XULDocument.h
dom/xul/nsXULCommandDispatcher.cpp
dom/xul/nsXULContentSink.cpp
dom/xul/templates/nsContentTestNode.cpp
dom/xul/templates/nsInstantiationNode.cpp
dom/xul/templates/nsRDFConInstanceTestNode.cpp
dom/xul/templates/nsRDFConMemberTestNode.cpp
dom/xul/templates/nsRDFPropertyTestNode.cpp
dom/xul/templates/nsRuleNetwork.cpp
dom/xul/templates/nsXULContentUtils.cpp
dom/xul/templates/nsXULTemplateBuilder.cpp
dom/xul/templates/nsXULTemplateBuilder.h
dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
--- a/dom/base/ThirdPartyUtil.cpp
+++ b/dom/base/ThirdPartyUtil.cpp
@@ -18,31 +18,28 @@
 #include "nsThreadUtils.h"
 #include "mozilla/Logging.h"
 
 NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
 
 //
 // NSPR_LOG_MODULES=thirdPartyUtil:5
 //
-static PRLogModuleInfo *gThirdPartyLog;
+static mozilla::LazyLogModule gThirdPartyLog("thirdPartyUtil");
 #undef LOG
 #define LOG(args)     MOZ_LOG(gThirdPartyLog, mozilla::LogLevel::Debug, args)
 
 nsresult
 ThirdPartyUtil::Init()
 {
   NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_NOT_AVAILABLE);
 
   nsresult rv;
   mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv);
 
-    if (!gThirdPartyLog)
-        gThirdPartyLog = PR_NewLogModule("thirdPartyUtil");
-
   return rv;
 }
 
 // Determine if aFirstDomain is a different base domain to aSecondURI; or, if
 // the concept of base domain does not apply, determine if the two hosts are not
 // string-identical.
 nsresult
 ThirdPartyUtil::IsThirdPartyInternal(const nsCString& aFirstDomain,
--- a/dom/base/nsContentPolicy.cpp
+++ b/dom/base/nsContentPolicy.cpp
@@ -25,33 +25,30 @@
 #include "nsCOMArray.h"
 #include "nsContentUtils.h"
 #include "mozilla/dom/nsMixedContentBlocker.h"
 
 using mozilla::LogLevel;
 
 NS_IMPL_ISUPPORTS(nsContentPolicy, nsIContentPolicy)
 
-static PRLogModuleInfo* gConPolLog;
+static mozilla::LazyLogModule gConPolLog("nsContentPolicy");
 
 nsresult
 NS_NewContentPolicy(nsIContentPolicy **aResult)
 {
   *aResult = new nsContentPolicy;
   NS_ADDREF(*aResult);
   return NS_OK;
 }
 
 nsContentPolicy::nsContentPolicy()
     : mPolicies(NS_CONTENTPOLICY_CATEGORY)
     , mSimplePolicies(NS_SIMPLECONTENTPOLICY_CATEGORY)
 {
-    if (! gConPolLog) {
-        gConPolLog = PR_NewLogModule("nsContentPolicy");
-    }
 }
 
 nsContentPolicy::~nsContentPolicy()
 {
 }
 
 #ifdef DEBUG
 #define WARN_IF_URI_UNINITIALIZED(uri,name)                         \
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -46,29 +46,26 @@
 #include "nsIWebNavigation.h"
 #include "nsGenericHTMLElement.h"
 #include "nsHTMLDNSPrefetch.h"
 #include "nsIObserverService.h"
 #include "mozilla/Preferences.h"
 #include "nsParserConstants.h"
 #include "nsSandboxFlags.h"
 
-static PRLogModuleInfo*
+using namespace mozilla;
+
+static LogModule*
 GetSriLog()
 {
-  static PRLogModuleInfo *gSriPRLog;
-  if (!gSriPRLog) {
-    gSriPRLog = PR_NewLogModule("SRI");
-  }
+  static LazyLogModule gSriPRLog("SRI");
   return gSriPRLog;
 }
 
-using namespace mozilla;
-
-PRLogModuleInfo* gContentSinkLogModuleInfo;
+LazyLogModule gContentSinkLogModuleInfo("nscontentsink");
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsContentSink)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsContentSink)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsContentSink)
   NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
@@ -105,22 +102,16 @@ nsContentSink::nsContentSink()
   NS_ASSERTION(!mDynamicLowerValue, "What?");
   NS_ASSERTION(!mParsing, "What?");
   NS_ASSERTION(mLastSampledUserEventTime == 0, "What?");
   NS_ASSERTION(mDeflectedCount == 0, "What?");
   NS_ASSERTION(!mDroppedTimer, "What?");
   NS_ASSERTION(mInMonolithicContainer == 0, "What?");
   NS_ASSERTION(mInNotification == 0, "What?");
   NS_ASSERTION(!mDeferredLayoutStart, "What?");
-
-#ifdef DEBUG
-  if (!gContentSinkLogModuleInfo) {
-    gContentSinkLogModuleInfo = PR_NewLogModule("nscontentsink");
-  }
-#endif
 }
 
 nsContentSink::~nsContentSink()
 {
   if (mDocument) {
     // Remove ourselves just to be safe, though we really should have
     // been removed in DidBuildModel if everything worked right.
     mDocument->RemoveObserver(this);
@@ -958,18 +949,20 @@ nsContentSink::SelectDocAppCache(nsIAppl
     else {
       // The http manifest attribute URI is equal to the manifest URI of
       // the cache the document was loaded from - associate the document with
       // that cache and invoke the cache update process.
 #ifdef DEBUG
       nsAutoCString docURISpec, clientID;
       mDocumentURI->GetAsciiSpec(docURISpec);
       aLoadApplicationCache->GetClientID(clientID);
-      SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
-          ("Selection: assigning app cache %s to document %s", clientID.get(), docURISpec.get()));
+      SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+                 SINK_TRACE_CALLS,
+                ("Selection: assigning app cache %s to document %s",
+                  clientID.get(), docURISpec.get()));
 #endif
 
       rv = applicationCacheDocument->SetApplicationCache(aLoadApplicationCache);
       NS_ENSURE_SUCCESS(rv, rv);
 
       // Document will be added as implicit entry to the cache as part of
       // the update process.
       *aAction = CACHE_SELECTION_UPDATE;
@@ -1012,18 +1005,20 @@ nsContentSink::SelectDocAppCacheNoManife
       do_QueryInterface(mDocument);
     NS_ASSERTION(applicationCacheDocument,
                  "mDocument must implement nsIApplicationCacheContainer.");
 
 #ifdef DEBUG
     nsAutoCString docURISpec, clientID;
     mDocumentURI->GetAsciiSpec(docURISpec);
     aLoadApplicationCache->GetClientID(clientID);
-    SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
-        ("Selection, no manifest: assigning app cache %s to document %s", clientID.get(), docURISpec.get()));
+    SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+               SINK_TRACE_CALLS,
+             ("Selection, no manifest: assigning app cache %s to document %s",
+               clientID.get(), docURISpec.get()));
 #endif
 
     rv = applicationCacheDocument->SetApplicationCache(aLoadApplicationCache);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Return the uri and invoke the update process for the selected
     // application cache.
     rv = aLoadApplicationCache->GetManifestURI(aManifestURI);
@@ -1327,31 +1322,33 @@ nsContentSink::IsTimeToNotify()
   return false;
 }
 
 nsresult
 nsContentSink::WillInterruptImpl()
 {
   nsresult result = NS_OK;
 
-  SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
+  SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+             SINK_TRACE_CALLS,
              ("nsContentSink::WillInterrupt: this=%p", this));
 #ifndef SINK_NO_INCREMENTAL
   if (WaitForPendingSheets()) {
     mDeferredFlushTags = true;
   } else if (sNotifyOnTimer && mLayoutStarted) {
     if (mBackoffCount && !mInMonolithicContainer) {
       int64_t now = PR_Now();
       int64_t interval = GetNotificationInterval();
       int64_t diff = now - mLastNotificationTime;
 
       // If it's already time for us to have a notification
       if (diff > interval || mDroppedTimer) {
         mBackoffCount--;
-        SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
+        SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+                   SINK_TRACE_REFLOW,
                    ("nsContentSink::WillInterrupt: flushing tags since we've "
                     "run out time; backoff count: %d", mBackoffCount));
         result = FlushTags();
         if (mDroppedTimer) {
           ScrollToRef();
           mDroppedTimer = false;
         }
       } else if (!mNotificationTimer) {
@@ -1359,46 +1356,49 @@ nsContentSink::WillInterruptImpl()
         int32_t delay = interval;
 
         // Convert to milliseconds
         delay /= PR_USEC_PER_MSEC;
 
         mNotificationTimer = do_CreateInstance("@mozilla.org/timer;1",
                                                &result);
         if (NS_SUCCEEDED(result)) {
-          SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
+          SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+                     SINK_TRACE_REFLOW,
                      ("nsContentSink::WillInterrupt: setting up timer with "
                       "delay %d", delay));
 
           result =
             mNotificationTimer->InitWithCallback(this, delay,
                                                  nsITimer::TYPE_ONE_SHOT);
           if (NS_FAILED(result)) {
             mNotificationTimer = nullptr;
           }
         }
       }
     }
   } else {
-    SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
+    SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+               SINK_TRACE_REFLOW,
                ("nsContentSink::WillInterrupt: flushing tags "
                 "unconditionally"));
     result = FlushTags();
   }
 #endif
 
   mParsing = false;
 
   return result;
 }
 
 nsresult
 nsContentSink::WillResumeImpl()
 {
-  SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
+  SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+             SINK_TRACE_CALLS,
              ("nsContentSink::WillResume: this=%p", this));
 
   mParsing = true;
 
   return NS_OK;
 }
 
 nsresult
@@ -1508,17 +1508,18 @@ nsContentSink::DidBuildModelImpl(bool aT
   }
 
   if (!mDocument->HaveFiredDOMTitleChange()) {
     mDocument->NotifyPossibleTitleChange(false);
   }
 
   // Cancel a timer if we had one out there
   if (mNotificationTimer) {
-    SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
+    SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
+               SINK_TRACE_REFLOW,
                ("nsContentSink::DidBuildModel: canceling notification "
                 "timeout"));
     mNotificationTimer->Cancel();
     mNotificationTimer = 0;
   }	
 }
 
 void
--- a/dom/base/nsContentSink.h
+++ b/dom/base/nsContentSink.h
@@ -42,23 +42,23 @@ class nsIApplicationCache;
 namespace mozilla {
 namespace css {
 class Loader;
 } // namespace css
 } // namespace mozilla
 
 #ifdef DEBUG
 
-extern PRLogModuleInfo* gContentSinkLogModuleInfo;
+extern mozilla::LazyLogModule gContentSinkLogModuleInfo;
 
 #define SINK_TRACE_CALLS              0x1
 #define SINK_TRACE_REFLOW             0x2
 #define SINK_ALWAYS_REFLOW            0x4
 
-#define SINK_LOG_TEST(_lm, _bit) (int((_lm)->level) & (_bit))
+#define SINK_LOG_TEST(_lm, _bit) (int((_lm)->Level()) & (_bit))
 
 #define SINK_TRACE(_lm, _bit, _args) \
   PR_BEGIN_MACRO                     \
     if (SINK_LOG_TEST(_lm, _bit)) {  \
       PR_LogPrint _args;             \
     }                                \
   PR_END_MACRO
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -252,18 +252,18 @@
 #include "IPeerConnection.h"
 #endif // MOZ_WEBRTC
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 typedef nsTArray<Link*> LinkArray;
 
-static PRLogModuleInfo* gDocumentLeakPRLog;
-static PRLogModuleInfo* gCspPRLog;
+static LazyLogModule gDocumentLeakPRLog("DocumentLeak");
+static LazyLogModule gCspPRLog("CSP");
 
 #define NAME_NOT_VALID ((nsSimpleContentList*)1)
 
 nsIdentifierMapEntry::~nsIdentifierMapEntry()
 {
 }
 
 void
@@ -1454,26 +1454,20 @@ nsIDocument::nsIDocument()
 
 nsDocument::nsDocument(const char* aContentType)
   : nsIDocument()
   , mAnimatingImages(true)
   , mViewportType(Unknown)
 {
   SetContentTypeInternal(nsDependentCString(aContentType));
 
-  if (!gDocumentLeakPRLog)
-    gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak");
-
   if (gDocumentLeakPRLog)
     MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
            ("DOCUMENT %p created", this));
 
-  if (!gCspPRLog)
-    gCspPRLog = PR_NewLogModule("CSP");
-
   // Start out mLastStyleSheetSet as null, per spec
   SetDOMStringToNull(mLastStyleSheetSet);
 
   // void state used to differentiate an empty source from an unselected source
   mPreloadPictureFoundSource.SetIsVoid(true);
 
   if (!sProcessingStack) {
     sProcessingStack.emplace();
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -72,18 +72,18 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::widget;
 
 // Two types of focus pr logging are available:
 //   'Focus' for normal focus manager calls
 //   'FocusNavigation' for tab and document navigation
-PRLogModuleInfo* gFocusLog;
-PRLogModuleInfo* gFocusNavigationLog;
+LazyLogModule gFocusLog("Focus");
+LazyLogModule gFocusNavigationLog("FocusNavigation");
 
 #define LOGFOCUS(args) MOZ_LOG(gFocusLog, mozilla::LogLevel::Debug, args)
 #define LOGFOCUSNAVIGATION(args) MOZ_LOG(gFocusNavigationLog, mozilla::LogLevel::Debug, args)
 
 #define LOGTAG(log, format, content)                            \
   if (MOZ_LOG_TEST(log, LogLevel::Debug)) {                         \
     nsAutoCString tag(NS_LITERAL_CSTRING("(none)"));            \
     if (content) {                                              \
@@ -188,19 +188,16 @@ nsFocusManager::~nsFocusManager()
 // static
 nsresult
 nsFocusManager::Init()
 {
   nsFocusManager* fm = new nsFocusManager();
   NS_ADDREF(fm);
   sInstance = fm;
 
-  gFocusLog = PR_NewLogModule("Focus");
-  gFocusNavigationLog = PR_NewLogModule("FocusNavigation");
-
   nsIContent::sTabFocusModelAppliesToXUL =
     Preferences::GetBool("accessibility.tabfocus_applies_to_xul",
                          nsIContent::sTabFocusModelAppliesToXUL);
 
   sMouseFocusesFormControl =
     Preferences::GetBool("accessibility.mouse_focuses_formcontrol", false);
 
   sTestMode = Preferences::GetBool("focusmanager.testmode", false);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -243,18 +243,16 @@ class nsIScriptTimeoutHandler;
 #undef check
 #endif // check
 #include "AccessCheck.h"
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 
-static PRLogModuleInfo* gDOMLeakPRLog;
-
 #ifdef XP_WIN
 #include <process.h>
 #define getpid _getpid
 #else
 #include <unistd.h> // for getpid()
 #endif
 
 static const char kStorageEnabled[] = "dom.storage.enabled";
@@ -264,16 +262,18 @@ using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 using mozilla::BasePrincipal;
 using mozilla::OriginAttributes;
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 using mozilla::dom::cache::CacheStorage;
 using mozilla::dom::indexedDB::IDBFactory;
 
+static LazyLogModule gDOMLeakPRLog("DOMLeak");
+
 nsGlobalWindow::WindowByIdTable *nsGlobalWindow::sWindowsById = nullptr;
 bool nsGlobalWindow::sWarnedAboutWindowInternal = false;
 bool nsGlobalWindow::sIdleObserversAPIFuzzTimeDisabled = false;
 
 static nsIEntropyCollector *gEntropyCollector          = nullptr;
 static int32_t              gRefCnt                    = 0;
 static int32_t              gOpenPopupSpamCount        = 0;
 static PopupControlState    gPopupControlState         = openAbused;
@@ -1273,17 +1273,16 @@ void
 nsGlobalWindow::Init()
 {
   AssertIsOnMainThread();
 
   CallGetService(NS_ENTROPYCOLLECTOR_CONTRACTID, &gEntropyCollector);
   NS_ASSERTION(gEntropyCollector,
                "gEntropyCollector should have been initialized!");
 
-  gDOMLeakPRLog = PR_NewLogModule("DOMLeak");
   NS_ASSERTION(gDOMLeakPRLog, "gDOMLeakPRLog should have been initialized!");
 
   sWindowsById = new WindowByIdTable();
 }
 
 nsGlobalWindow::~nsGlobalWindow()
 {
   AssertIsOnMainThread();
--- a/dom/base/nsNodeInfoManager.cpp
+++ b/dom/base/nsNodeInfoManager.cpp
@@ -31,17 +31,17 @@
 #include "nsDocument.h"
 #include "nsNullPrincipal.h"
 
 using namespace mozilla;
 using mozilla::dom::NodeInfo;
 
 #include "mozilla/Logging.h"
 
-static PRLogModuleInfo* gNodeInfoManagerLeakPRLog;
+static LazyLogModule gNodeInfoManagerLeakPRLog("NodeInfoManagerLeak");
 
 PLHashNumber
 nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key)
 {
   MOZ_ASSERT(key, "Null key passed to NodeInfo::GetHashValue!");
 
   auto *node = reinterpret_cast<const NodeInfo::NodeInfoInner*>(key);
 
@@ -110,19 +110,16 @@ nsNodeInfoManager::nsNodeInfoManager()
   : mDocument(nullptr),
     mNonDocumentNodeInfos(0),
     mTextNodeInfo(nullptr),
     mCommentNodeInfo(nullptr),
     mDocumentNodeInfo(nullptr)
 {
   nsLayoutStatics::AddRef();
 
-  if (!gNodeInfoManagerLeakPRLog)
-    gNodeInfoManagerLeakPRLog = PR_NewLogModule("NodeInfoManagerLeak");
-
   if (gNodeInfoManagerLeakPRLog)
     MOZ_LOG(gNodeInfoManagerLeakPRLog, LogLevel::Debug,
            ("NODEINFOMANAGER %p created", this));
 
   mNodeInfoHash = PL_NewHashTable(32, GetNodeInfoInnerHashValue,
                                   NodeInfoInnerKeyCompare,
                                   PL_CompareValues, &allocOps, nullptr);
 }
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -102,22 +102,20 @@
 
 static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
 
 static const char *kPrefJavaMIME = "plugin.java.mime";
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
-static PRLogModuleInfo*
+static LogModule*
 GetObjectLog()
 {
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("objlc");
+  static LazyLogModule sLog("objlc");
   return sLog;
 }
 
 #define LOG(args) MOZ_LOG(GetObjectLog(), mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(GetObjectLog(), mozilla::LogLevel::Debug)
 
 static bool
 IsJavaMIME(const nsACString & aMIMEType)
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -52,31 +52,28 @@
 #include "ImportManager.h"
 #include "mozilla/dom/EncodingUtils.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/unused.h"
 #include "mozilla/dom/SRICheck.h"
 #include "nsIScriptError.h"
 
-static PRLogModuleInfo* gCspPRLog;
+using namespace mozilla;
+using namespace mozilla::dom;
 
-static PRLogModuleInfo*
+static LazyLogModule gCspPRLog("CSP");
+
+static LogModule*
 GetSriLog()
 {
-  static PRLogModuleInfo *gSriPRLog;
-  if (!gSriPRLog) {
-    gSriPRLog = PR_NewLogModule("SRI");
-  }
+  static LazyLogModule gSriPRLog("SRI");
   return gSriPRLog;
 }
 
-using namespace mozilla;
-using namespace mozilla::dom;
-
 // The nsScriptLoadRequest is passed as the context to necko, and thus
 // it needs to be threadsafe. Necko won't do anything with this
 // context, but it will AddRef and Release it on other threads.
 NS_IMPL_ISUPPORTS0(nsScriptLoadRequest)
 
 nsScriptLoadRequestList::~nsScriptLoadRequestList()
 {
   Clear();
@@ -115,19 +112,16 @@ nsScriptLoader::nsScriptLoader(nsIDocume
   : mDocument(aDocument),
     mBlockerCount(0),
     mNumberOfProcessors(0),
     mEnabled(true),
     mDeferEnabled(false),
     mDocumentParsingDone(false),
     mBlockingDOMContentLoaded(false)
 {
-  // enable logging for CSP
-  if (!gCspPRLog)
-    gCspPRLog = PR_NewLogModule("CSP");
 }
 
 nsScriptLoader::~nsScriptLoader()
 {
   mObservers.Clear();
 
   if (mParserBlockingRequest) {
     mParserBlockingRequest->FireScriptAvailable(NS_ERROR_ABORT);
--- a/dom/base/nsStyleLinkElement.cpp
+++ b/dom/base/nsStyleLinkElement.cpp
@@ -26,29 +26,26 @@
 #include "nsUnicharUtils.h"
 #include "nsCRT.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsUnicharInputStream.h"
 #include "nsContentUtils.h"
 #include "nsStyleUtil.h"
 #include "nsQueryObject.h"
 
-static PRLogModuleInfo*
+using namespace mozilla;
+using namespace mozilla::dom;
+
+static LogModule*
 GetSriLog()
 {
-  static PRLogModuleInfo *gSriPRLog;
-  if (!gSriPRLog) {
-    gSriPRLog = PR_NewLogModule("SRI");
-  }
+  static LazyLogModule gSriPRLog("SRI");
   return gSriPRLog;
 }
 
-using namespace mozilla;
-using namespace mozilla::dom;
-
 nsStyleLinkElement::nsStyleLinkElement()
   : mDontLoadStyle(false)
   , mUpdatesEnabled(true)
   , mLineNumber(1)
 {
 }
 
 nsStyleLinkElement::~nsStyleLinkElement()
--- a/dom/camera/CameraCommon.h
+++ b/dom/camera/CameraCommon.h
@@ -4,17 +4,17 @@
  * 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/. */
 
 #ifndef DOM_CAMERA_CAMERACOMMON_H
 #define DOM_CAMERA_CAMERACOMMON_H
 
 #include "mozilla/Logging.h"
 
-extern PRLogModuleInfo* GetCameraLog();
+extern mozilla::LogModule* GetCameraLog();
 #define DOM_CAMERA_LOG( type, ... ) MOZ_LOG(GetCameraLog(), (mozilla::LogLevel)type, ( __VA_ARGS__ ))
 
 #define DOM_CAMERA_LOGA( ... )      DOM_CAMERA_LOG( mozilla::LogLevel::Error, __VA_ARGS__ )
 
 /**
  * From the least to the most output.
  */
 enum {
--- a/dom/camera/DOMCameraManager.cpp
+++ b/dom/camera/DOMCameraManager.cpp
@@ -37,23 +37,20 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCam
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCameraManager)
 
 /**
  * Global camera logging object
  *
  * Set the NSPR_LOG_MODULES environment variable to enable logging
  * in a debug build, e.g. NSPR_LOG_MODULES=Camera:5
  */
-PRLogModuleInfo*
+LogModule*
 GetCameraLog()
 {
-  static PRLogModuleInfo *sLog;
-  if (!sLog) {
-    sLog = PR_NewLogModule("Camera");
-  }
+  static LazyLogModule sLog("Camera");
   return sLog;
 }
 
 ::WindowTable* nsDOMCameraManager::sActiveWindows = nullptr;
 
 nsDOMCameraManager::nsDOMCameraManager(nsPIDOMWindow* aWindow)
   : mWindowId(aWindow->WindowID())
   , mPermission(nsIPermissionManager::DENY_ACTION)
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -35,17 +35,17 @@
 #include "nsPresContext.h"
 #include "nsWeakReference.h"
 #include "WritingModes.h"
 
 namespace mozilla {
 
 using namespace widget;
 
-PRLogModuleInfo* sIMECOLog = nullptr;
+LazyLogModule sIMECOLog("IMEContentObserver");
 
 static const char*
 ToChar(bool aBool)
 {
   return aBool ? "true" : "false";
 }
 
 static const char*
@@ -202,19 +202,16 @@ IMEContentObserver::IMEContentObserver()
   , mNeedsToNotifyIMEOfTextChange(false)
   , mNeedsToNotifyIMEOfSelectionChange(false)
   , mNeedsToNotifyIMEOfPositionChange(false)
   , mIsHandlingQueryContentEvent(false)
 {
 #ifdef DEBUG
   mTextChangeData.Test();
 #endif
-  if (!sIMECOLog) {
-    sIMECOLog = PR_NewLogModule("IMEContentObserver");
-  }
 }
 
 void
 IMEContentObserver::Init(nsIWidget* aWidget,
                          nsPresContext* aPresContext,
                          nsIContent* aContent,
                          nsIEditor* aEditor)
 {
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -52,17 +52,17 @@ using namespace widget;
  * When a method quits due to unexpected situation, log the reason with
  * LogLevel::Error.  In this case, the log should start with
  * "ISM:   <method name>(), FAILED".  The indent makes the log look easier.
  *
  * When a method does something only in some situations and it may be important
  * for debug, log the information with LogLevel::Debug.  In this case, the log
  * should start with "ISM:   <method name>(),".
  */
-PRLogModuleInfo* sISMLog = nullptr;
+LazyLogModule sISMLog("IMEStateManager");
 
 static const char*
 GetBoolName(bool aBool)
 {
   return aBool ? "true" : "false";
 }
 
 static const char*
@@ -170,20 +170,16 @@ bool IMEStateManager::sInstalledMenuKeyb
 bool IMEStateManager::sIsGettingNewIMEState = false;
 bool IMEStateManager::sCheckForIMEUnawareWebApps = false;
 bool IMEStateManager::sRemoteHasFocus = false;
 
 // static
 void
 IMEStateManager::Init()
 {
-  if (!sISMLog) {
-    sISMLog = PR_NewLogModule("IMEStateManager");
-  }
-
   Preferences::AddBoolVarCache(
     &sCheckForIMEUnawareWebApps,
     "intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition",
     false);
 }
 
 // static
 void
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -86,18 +86,19 @@
 #include "nsIContentPolicy.h"
 #include "mozilla/Telemetry.h"
 
 #include "ImageContainer.h"
 #include "nsRange.h"
 #include <algorithm>
 #include <cmath>
 
-static PRLogModuleInfo* gMediaElementLog;
-static PRLogModuleInfo* gMediaElementEventsLog;
+static mozilla::LazyLogModule gMediaElementLog("nsMediaElement");
+static mozilla::LazyLogModule gMediaElementEventsLog("nsMediaElementEvents");
+
 #define LOG(type, msg) MOZ_LOG(gMediaElementLog, type, msg)
 #define LOG_EVENT(type, msg) MOZ_LOG(gMediaElementEventsLog, type, msg)
 
 #include "nsIContentSecurityPolicy.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/FloatingPoint.h"
 
@@ -2106,23 +2107,16 @@ HTMLMediaElement::HTMLMediaElement(alrea
     mDisableVideo(false),
     mPlayBlockedBecauseHidden(false),
     mMediaStreamTrackListener(nullptr),
     mElementInTreeState(ELEMENT_NOT_INTREE),
     mHasUserInteraction(false),
     mFirstFrameLoaded(false),
     mDefaultPlaybackStartPosition(0.0)
 {
-  if (!gMediaElementLog) {
-    gMediaElementLog = PR_NewLogModule("nsMediaElement");
-  }
-  if (!gMediaElementEventsLog) {
-    gMediaElementEventsLog = PR_NewLogModule("nsMediaElementEvents");
-  }
-
   mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
 
   mPaused.SetOuter(this);
 
   RegisterActivityObserver();
   NotifyOwnerDocumentActivityChangedInternal();
 
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -35,17 +35,17 @@
 #include "nsISupportsImpl.h"
 #include "nsMappedAttributes.h"
 #include "nsNetUtil.h"
 #include "nsRuleData.h"
 #include "nsStyleConsts.h"
 #include "nsThreadUtils.h"
 #include "nsVideoFrame.h"
 
-static PRLogModuleInfo* gTrackElementLog;
+static mozilla::LazyLogModule gTrackElementLog("nsTrackElement");
 #define LOG(type, msg) MOZ_LOG(gTrackElementLog, type, msg)
 
 // Replace the usual NS_IMPL_NS_NEW_HTML_ELEMENT(Track) so
 // we can return an UnknownElement instead when pref'd off.
 nsGenericHTMLElement*
 NS_NewHTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                        mozilla::dom::FromParser aFromParser)
 {
@@ -71,19 +71,16 @@ static MOZ_CONSTEXPR nsAttrValue::EnumTa
 
 // The default value for kKindTable is "subtitles"
 static MOZ_CONSTEXPR const char* kKindTableDefaultString = kKindTable[0].tag;
 
 /** HTMLTrackElement */
 HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo)
 {
-  if (!gTrackElementLog) {
-    gTrackElementLog = PR_NewLogModule("nsTrackElement");
-  }
 }
 
 HTMLTrackElement::~HTMLTrackElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLTrackElement)
 
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -257,17 +257,17 @@ IndexedDatabaseManager::~IndexedDatabase
     mBackgroundActor->SendDeleteMeInternal();
     MOZ_ASSERT(!mBackgroundActor, "SendDeleteMeInternal should have cleared!");
   }
 }
 
 bool IndexedDatabaseManager::sIsMainProcess = false;
 bool IndexedDatabaseManager::sFullSynchronousMode = false;
 
-PRLogModuleInfo* IndexedDatabaseManager::sLoggingModule;
+mozilla::LazyLogModule IndexedDatabaseManager::sLoggingModule("IndexedDB");
 
 Atomic<IndexedDatabaseManager::LoggingMode>
   IndexedDatabaseManager::sLoggingMode(
     IndexedDatabaseManager::Logging_Disabled);
 
 mozilla::Atomic<bool> IndexedDatabaseManager::sLowDiskSpaceMode(false);
 
 // static
@@ -279,20 +279,16 @@ IndexedDatabaseManager::GetOrCreate()
   if (IsClosed()) {
     NS_ERROR("Calling GetOrCreate() after shutdown!");
     return nullptr;
   }
 
   if (!gDBManager) {
     sIsMainProcess = XRE_IsParentProcess();
 
-    if (!sLoggingModule) {
-      sLoggingModule = PR_NewLogModule("IndexedDB");
-    }
-
     if (sIsMainProcess && Preferences::GetBool("disk_space_watcher.enabled", false)) {
       // See if we're starting up in low disk space conditions.
       nsCOMPtr<nsIDiskSpaceWatcher> watcher =
         do_GetService(DISKSPACEWATCHER_CONTRACTID);
       if (watcher) {
         bool isDiskFull;
         if (NS_SUCCEEDED(watcher->GetIsDiskFull(&isDiskFull))) {
           sLowDiskSpaceMode = isDiskFull;
@@ -669,17 +665,17 @@ IndexedDatabaseManager::GetLoggingMode()
   MOZ_ASSERT(gDBManager,
              "GetLoggingMode called before IndexedDatabaseManager has been "
              "initialized!");
 
   return sLoggingMode;
 }
 
 // static
-PRLogModuleInfo*
+mozilla::LogModule*
 IndexedDatabaseManager::GetLoggingModule()
 {
   MOZ_ASSERT(gDBManager,
              "GetLoggingModule called before IndexedDatabaseManager has been "
              "initialized!");
 
   return sLoggingModule;
 }
--- a/dom/indexedDB/IndexedDatabaseManager.h
+++ b/dom/indexedDB/IndexedDatabaseManager.h
@@ -14,17 +14,16 @@
 #include "mozilla/dom/quota/PersistenceType.h"
 #include "mozilla/Mutex.h"
 #include "nsClassHashtable.h"
 #include "nsCOMPtr.h"
 #include "nsHashKeys.h"
 #include "nsITimer.h"
 
 class nsIEventTarget;
-struct PRLogModuleInfo;
 
 namespace mozilla {
 
 class EventChainPostVisitor;
 
 namespace dom {
 
 namespace indexedDB {
@@ -96,17 +95,17 @@ public:
 #ifdef DEBUG
   ;
 #else
   {
     return sLoggingMode;
   }
 #endif
 
-  static PRLogModuleInfo*
+  static mozilla::LogModule*
   GetLoggingModule()
 #ifdef DEBUG
   ;
 #else
   {
     return sLoggingModule;
   }
 #endif
@@ -221,17 +220,17 @@ private:
 #ifdef ENABLE_INTL_API
   nsCString mLocale;
 #endif
 
   BackgroundUtilsChild* mBackgroundActor;
 
   static bool sIsMainProcess;
   static bool sFullSynchronousMode;
-  static PRLogModuleInfo* sLoggingModule;
+  static LazyLogModule sLoggingModule;
   static Atomic<LoggingMode> sLoggingMode;
   static mozilla::Atomic<bool> sLowDiskSpaceMode;
 };
 
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/indexedDB/ProfilerHelpers.h
+++ b/dom/indexedDB/ProfilerHelpers.h
@@ -274,17 +274,17 @@ public:
 
 inline void
 LoggingHelper(bool aUseProfiler, const char* aFmt, ...)
 {
   MOZ_ASSERT(IndexedDatabaseManager::GetLoggingMode() !=
                IndexedDatabaseManager::Logging_Disabled);
   MOZ_ASSERT(aFmt);
 
-  PRLogModuleInfo* logModule = IndexedDatabaseManager::GetLoggingModule();
+  mozilla::LogModule* logModule = IndexedDatabaseManager::GetLoggingModule();
   MOZ_ASSERT(logModule);
 
   static const mozilla::LogLevel logLevel = LogLevel::Warning;
 
   if (MOZ_LOG_TEST(logModule, logLevel) ||
       (aUseProfiler && profiler_is_active())) {
     nsAutoCString message;
 
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -23,16 +23,20 @@
 #include "StaticPtr.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsIObserver.h"
 #include "nsITimer.h"
 #include "nsIPropertyBag2.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCRT.h"
 
+using namespace mozilla;
+using namespace mozilla::dom;
+using namespace mozilla::hal;
+
 #ifdef XP_WIN
 #include <process.h>
 #define getpid _getpid
 #else
 #include <unistd.h>
 #endif
 
 #ifdef LOG
@@ -64,38 +68,32 @@
 #  define LOG(fmt, ...) \
      printf("ProcessPriorityManager - " fmt "\n", ##__VA_ARGS__)
 #  define LOGP(fmt, ...) \
      printf("ProcessPriorityManager[%schild-id=%" PRIu64 ", pid=%d] - " \
        fmt "\n", \
        NameWithComma().get(), \
        static_cast<uint64_t>(ChildID()), Pid(), ##__VA_ARGS__)
 #else
-  static PRLogModuleInfo*
+  static LogModule*
   GetPPMLog()
   {
-    static PRLogModuleInfo *sLog;
-    if (!sLog)
-      sLog = PR_NewLogModule("ProcessPriorityManager");
+    static LazyLogModule sLog("ProcessPriorityManager");
     return sLog;
   }
 #  define LOG(fmt, ...) \
      MOZ_LOG(GetPPMLog(), LogLevel::Debug, \
             ("ProcessPriorityManager - " fmt, ##__VA_ARGS__))
 #  define LOGP(fmt, ...) \
      MOZ_LOG(GetPPMLog(), LogLevel::Debug, \
             ("ProcessPriorityManager[%schild-id=%" PRIu64 ", pid=%d] - " fmt, \
             NameWithComma().get(), \
             static_cast<uint64_t>(ChildID()), Pid(), ##__VA_ARGS__))
 #endif
 
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::hal;
-
 namespace {
 
 class ParticularProcessPriorityManager;
 
 class ProcessLRUPool final
 {
 public:
   /**
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -168,19 +168,19 @@ static const char *kPluginRegistryVersio
 // The minimum registry version we know how to read
 static const char *kMinimumRegistryVersion = "0.9";
 
 static const char kDirectoryServiceContractID[] = "@mozilla.org/file/directory_service;1";
 
 #define kPluginRegistryFilename NS_LITERAL_CSTRING("pluginreg.dat")
 
 #ifdef PLUGIN_LOGGING
-PRLogModuleInfo* nsPluginLogging::gNPNLog = nullptr;
-PRLogModuleInfo* nsPluginLogging::gNPPLog = nullptr;
-PRLogModuleInfo* nsPluginLogging::gPluginLog = nullptr;
+LazyLogModule nsPluginLogging::gNPNLog(NPN_LOG_NAME);
+LazyLogModule nsPluginLogging::gNPPLog(NPP_LOG_NAME);
+LazyLogModule nsPluginLogging::gPluginLog(PLUGIN_LOG_NAME);
 #endif
 
 // #defines for plugin cache and prefs
 #define NS_PREF_MAX_NUM_CACHED_INSTANCES "browser.plugins.max_num_cached_plugins"
 // Raise this from '10' to '50' to work around a bug in Apple's current Java
 // plugins on OS X Lion and SnowLeopard.  See bug 705931.
 #define DEFAULT_NUMBER_OF_STOPPED_INSTANCES 50
 
@@ -315,20 +315,16 @@ nsPluginHost::nsPluginHost()
     obsService->AddObserver(this, "blocklist-updated", false);
 #ifdef MOZ_WIDGET_ANDROID
     obsService->AddObserver(this, "application-foreground", false);
     obsService->AddObserver(this, "application-background", false);
 #endif
   }
 
 #ifdef PLUGIN_LOGGING
-  nsPluginLogging::gNPNLog = PR_NewLogModule(NPN_LOG_NAME);
-  nsPluginLogging::gNPPLog = PR_NewLogModule(NPP_LOG_NAME);
-  nsPluginLogging::gPluginLog = PR_NewLogModule(PLUGIN_LOG_NAME);
-
   MOZ_LOG(nsPluginLogging::gNPNLog, PLUGIN_LOG_ALWAYS,("NPN Logging Active!\n"));
   MOZ_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_ALWAYS,("General Plugin Logging Active! (nsPluginHost::ctor)\n"));
   MOZ_LOG(nsPluginLogging::gNPPLog, PLUGIN_LOG_ALWAYS,("NPP Logging Active!\n"));
 
   PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("nsPluginHost::ctor\n"));
   PR_LogFlush();
 #endif
 }
--- a/dom/plugins/base/nsPluginLogging.h
+++ b/dom/plugins/base/nsPluginLogging.h
@@ -43,19 +43,19 @@
 //    http://www.mozilla.org/projects/nspr/reference/html/prlog.html
 
 
 #ifdef PLUGIN_LOGGING
 
 class nsPluginLogging
 {
 public:
-  static PRLogModuleInfo* gNPNLog;  // 4.x NP API, calls into navigator
-  static PRLogModuleInfo* gNPPLog;  // 4.x NP API, calls into plugin
-  static PRLogModuleInfo* gPluginLog;  // general plugin log
+  static mozilla::LazyLogModule gNPNLog;  // 4.x NP API, calls into navigator
+  static mozilla::LazyLogModule gNPPLog;  // 4.x NP API, calls into plugin
+  static mozilla::LazyLogModule gPluginLog;  // general plugin log
 };
 
 #endif   // PLUGIN_LOGGING
 
 // Quick-use macros
 #ifdef PLUGIN_LOGGING
  #define NPN_PLUGIN_LOG(a, b)                              \
    PR_BEGIN_MACRO                                        \
--- a/dom/plugins/ipc/PluginMessageUtils.cpp
+++ b/dom/plugins/ipc/PluginMessageUtils.cpp
@@ -115,22 +115,20 @@ UnmungePluginDsoPath(const string& munge
 #if defined(OS_LINUX)
   return ReplaceAll(munged, "netsc@pe", "netscape");
 #else
   return munged;
 #endif
 }
 
 
-PRLogModuleInfo*
+LogModule*
 GetPluginLog()
 {
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("IPCPlugins");
+  static LazyLogModule sLog("IPCPlugins");
   return sLog;
 }
 
 void
 DeferNPObjectLastRelease(const NPNetscapeFuncs* f, NPObject* o)
 {
   if (!o)
     return;
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -48,17 +48,17 @@ mozilla::ipc::RacyInterruptPolicy
 MediateRace(const mozilla::ipc::MessageChannel::Message& parent,
             const mozilla::ipc::MessageChannel::Message& child);
 
 std::string
 MungePluginDsoPath(const std::string& path);
 std::string
 UnmungePluginDsoPath(const std::string& munged);
 
-extern PRLogModuleInfo* GetPluginLog();
+extern mozilla::LogModule* GetPluginLog();
 
 #if defined(_MSC_VER)
 #define FULLFUNCTION __FUNCSIG__
 #elif defined(__GNUC__)
 #define FULLFUNCTION __PRETTY_FUNCTION__
 #else
 #define FULLFUNCTION __FUNCTION__
 #endif
--- a/dom/security/SRICheck.cpp
+++ b/dom/security/SRICheck.cpp
@@ -17,23 +17,20 @@
 #include "nsIScriptError.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIStreamLoader.h"
 #include "nsIUnicharStreamLoader.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsWhitespaceTokenizer.h"
 
-static PRLogModuleInfo*
+static mozilla::LogModule*
 GetSriLog()
 {
-  static PRLogModuleInfo *gSriPRLog;
-  if (!gSriPRLog) {
-    gSriPRLog = PR_NewLogModule("SRI");
-  }
+  static mozilla::LazyLogModule gSriPRLog("SRI");
   return gSriPRLog;
 }
 
 #define SRILOG(args) MOZ_LOG(GetSriLog(), mozilla::LogLevel::Debug, args)
 #define SRIERROR(args) MOZ_LOG(GetSriLog(), mozilla::LogLevel::Error, args)
 
 namespace mozilla {
 namespace dom {
--- a/dom/security/SRIMetadata.cpp
+++ b/dom/security/SRIMetadata.cpp
@@ -6,23 +6,20 @@
 
 #include "SRIMetadata.h"
 
 #include "hasht.h"
 #include "mozilla/dom/URLSearchParams.h"
 #include "mozilla/Logging.h"
 #include "nsICryptoHash.h"
 
-static PRLogModuleInfo*
+static mozilla::LogModule*
 GetSriMetadataLog()
 {
-  static PRLogModuleInfo *gSriMetadataPRLog;
-  if (!gSriMetadataPRLog) {
-    gSriMetadataPRLog = PR_NewLogModule("SRIMetadata");
-  }
+  static mozilla::LazyLogModule gSriMetadataPRLog("SRIMetadata");
   return gSriMetadataPRLog;
 }
 
 #define SRIMETADATALOG(args) MOZ_LOG(GetSriMetadataLog(), mozilla::LogLevel::Debug, args)
 #define SRIMETADATAERROR(args) MOZ_LOG(GetSriMetadataLog(), mozilla::LogLevel::Error, args)
 
 namespace mozilla {
 namespace dom {
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -40,22 +40,20 @@
 #include "mozilla/Logging.h"
 #include "mozilla/dom/CSPReportBinding.h"
 #include "mozilla/dom/CSPDictionariesBinding.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "nsINetworkInterceptController.h"
 
 using namespace mozilla;
 
-static PRLogModuleInfo *
+static LogModule*
 GetCspContextLog()
 {
-  static PRLogModuleInfo *gCspContextPRLog;
-  if (!gCspContextPRLog)
-    gCspContextPRLog = PR_NewLogModule("CSPContext");
+  static LazyLogModule gCspContextPRLog("CSPContext");
   return gCspContextPRLog;
 }
 
 #define CSPCONTEXTLOG(args) MOZ_LOG(GetCspContextLog(), mozilla::LogLevel::Debug, args)
 #define CSPCONTEXTLOGENABLED() MOZ_LOG_TEST(GetCspContextLog(), mozilla::LogLevel::Debug)
 
 static const uint32_t CSP_CACHE_URI_CUTOFF_SIZE = 512;
 
--- a/dom/security/nsCSPParser.cpp
+++ b/dom/security/nsCSPParser.cpp
@@ -14,22 +14,20 @@
 #include "nsNetUtil.h"
 #include "nsReadableUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
 using namespace mozilla;
 
-static PRLogModuleInfo*
+static LogModule*
 GetCspParserLog()
 {
-  static PRLogModuleInfo* gCspParserPRLog;
-  if (!gCspParserPRLog)
-    gCspParserPRLog = PR_NewLogModule("CSPParser");
+  static LazyLogModule gCspParserPRLog("CSPParser");
   return gCspParserPRLog;
 }
 
 #define CSPPARSERLOG(args) MOZ_LOG(GetCspParserLog(), mozilla::LogLevel::Debug, args)
 #define CSPPARSERLOGENABLED() MOZ_LOG_TEST(GetCspParserLog(), mozilla::LogLevel::Debug)
 
 static const char16_t COLON        = ':';
 static const char16_t SEMICOLON    = ';';
--- a/dom/security/nsCSPService.cpp
+++ b/dom/security/nsCSPService.cpp
@@ -22,24 +22,21 @@
 #include "nsContentPolicyUtils.h"
 #include "nsPrincipal.h"
 
 using namespace mozilla;
 
 /* Keeps track of whether or not CSP is enabled */
 bool CSPService::sCSPEnabled = true;
 
-static PRLogModuleInfo* gCspPRLog;
+static LazyLogModule gCspPRLog("CSP");
 
 CSPService::CSPService()
 {
   Preferences::AddBoolVarCache(&sCSPEnabled, "security.csp.enable");
-
-  if (!gCspPRLog)
-    gCspPRLog = PR_NewLogModule("CSP");
 }
 
 CSPService::~CSPService()
 {
   mAppStatusCache.Clear();
 }
 
 NS_IMPL_ISUPPORTS(CSPService, nsIContentPolicy, nsIChannelEventSink)
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -9,22 +9,20 @@
 #include "nsIConsoleService.h"
 #include "nsICryptoHash.h"
 #include "nsIScriptError.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsIURL.h"
 #include "nsReadableUtils.h"
 
-static PRLogModuleInfo*
+static mozilla::LogModule*
 GetCspUtilsLog()
 {
-  static PRLogModuleInfo* gCspUtilsPRLog;
-  if (!gCspUtilsPRLog)
-    gCspUtilsPRLog = PR_NewLogModule("CSPUtils");
+  static mozilla::LazyLogModule gCspUtilsPRLog("CSPUtils");
   return gCspUtilsPRLog;
 }
 
 #define CSPUTILSLOG(args) MOZ_LOG(GetCspUtilsLog(), mozilla::LogLevel::Debug, args)
 #define CSPUTILSLOGENABLED() MOZ_LOG_TEST(GetCspUtilsLog(), mozilla::LogLevel::Debug)
 
 void
 CSP_GetLocalizedStr(const char16_t* aName,
--- a/dom/system/gonk/mozstumbler/StumblerLogging.cpp
+++ b/dom/system/gonk/mozstumbler/StumblerLogging.cpp
@@ -1,13 +1,13 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* 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 "StumblerLogging.h"
 
-PRLogModuleInfo* GetLog()
+mozilla::LogModule* GetLog()
 {
-  static PRLogModuleInfo* log = PR_NewLogModule("mozstumbler");
+  static mozilla::LazyLogModule log("mozstumbler");
   return log;
 }
--- a/dom/system/gonk/mozstumbler/StumblerLogging.h
+++ b/dom/system/gonk/mozstumbler/StumblerLogging.h
@@ -4,15 +4,15 @@
  * 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/. */
 
 #ifndef STUMBLERLOGGING_H
 #define STUMBLERLOGGING_H
 
 #include "mozilla/Logging.h"
 
-PRLogModuleInfo* GetLog();
+mozilla::LogModule* GetLog();
 
 #define STUMBLER_DBG(arg, ...)  MOZ_LOG(GetLog(), mozilla::LogLevel::Debug, ("STUMBLER - %s: " arg, __func__, ##__VA_ARGS__))
 #define STUMBLER_LOG(arg, ...)  MOZ_LOG(GetLog(), mozilla::LogLevel::Info, ("STUMBLER - %s: " arg, __func__, ##__VA_ARGS__))
 #define STUMBLER_ERR(arg, ...)  MOZ_LOG(GetLog(), mozilla::LogLevel::Error, ("STUMBLER -%s: " arg, __func__, ##__VA_ARGS__))
 
 #endif
--- a/dom/xslt/base/txLog.h
+++ b/dom/xslt/base/txLog.h
@@ -6,21 +6,19 @@
 #ifndef txLog_h__
 #define txLog_h__
 
 #include "mozilla/Logging.h"
 
 class txLog
 {
 public:
-    static PRLogModuleInfo *xpath;
-    static PRLogModuleInfo *xslt;
+    static mozilla::LazyLogModule xpath;
+    static mozilla::LazyLogModule xslt;
 };
 
 #define TX_LG_IMPL \
-    PRLogModuleInfo * txLog::xpath = 0; \
-    PRLogModuleInfo * txLog::xslt = 0;
+    mozilla::LazyLogModule txLog::xpath("xpath"); \
+    mozilla::LazyLogModule txLog::xslt("xslt");
 
-#define TX_LG_CREATE \
-    txLog::xpath = PR_NewLogModule("xpath"); \
-    txLog::xslt  = PR_NewLogModule("xslt")
+#define TX_LG_CREATE
 
 #endif
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -126,17 +126,17 @@ const nsForwardReference::Phase nsForwar
 
 //----------------------------------------------------------------------
 //
 // Statics
 //
 
 int32_t XULDocument::gRefCnt = 0;
 
-PRLogModuleInfo* XULDocument::gXULLog;
+LazyLogModule XULDocument::gXULLog("XULDocument");
 
 //----------------------------------------------------------------------
 
 struct BroadcastListener {
     nsWeakPtr mListener;
     nsCOMPtr<nsIAtom> mAttribute;
 };
 
@@ -1873,19 +1873,16 @@ XULDocument::Init()
           NS_ERROR("Could not instantiate nsXULPrototypeCache");
           return NS_ERROR_FAILURE;
         }
     }
 
     Preferences::RegisterCallback(XULDocument::DirectionChanged,
                                   "intl.uidirection.", this);
 
-    if (! gXULLog)
-        gXULLog = PR_NewLogModule("XULDocument");
-
     return NS_OK;
 }
 
 
 nsresult
 XULDocument::StartLayout(void)
 {
     mMayStartLayout = true;
--- a/dom/xul/XULDocument.h
+++ b/dom/xul/XULDocument.h
@@ -38,18 +38,16 @@ class nsIObjectOutputStream;
 #else
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsXULElement.h"
 #endif
 #include "nsURIHashKey.h"
 #include "nsInterfaceHashtable.h"
 
-struct PRLogModuleInfo;
-
 class nsRefMapEntry : public nsStringHashKey
 {
 public:
   explicit nsRefMapEntry(const nsAString& aKey) :
     nsStringHashKey(&aKey)
   {
   }
   explicit nsRefMapEntry(const nsAString* aKey) :
@@ -289,17 +287,17 @@ protected:
 
     static nsIAtom** kIdentityAttrs[];
 
     static nsIRDFService* gRDFService;
     static nsIRDFResource* kNC_persist;
     static nsIRDFResource* kNC_attribute;
     static nsIRDFResource* kNC_value;
 
-    static PRLogModuleInfo* gXULLog;
+    static LazyLogModule gXULLog;
 
     nsresult
     Persist(nsIContent* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute);
     // Just like Persist but ignores the return value so we can use it
     // as a runnable method.
     void DoPersist(nsIContent* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute)
     {
         Persist(aElement, aNameSpaceID, aAttribute);
--- a/dom/xul/nsXULCommandDispatcher.cpp
+++ b/dom/xul/nsXULCommandDispatcher.cpp
@@ -32,26 +32,23 @@
 #include "nsError.h"
 #include "nsDOMClassInfoID.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/Element.h"
 
 using namespace mozilla;
 
-static PRLogModuleInfo* gCommandLog;
+static LazyLogModule gCommandLog("nsXULCommandDispatcher");
 
 ////////////////////////////////////////////////////////////////////////
 
 nsXULCommandDispatcher::nsXULCommandDispatcher(nsIDocument* aDocument)
     : mDocument(aDocument), mUpdaters(nullptr)
 {
-
-  if (! gCommandLog)
-    gCommandLog = PR_NewLogModule("nsXULCommandDispatcher");
 }
 
 nsXULCommandDispatcher::~nsXULCommandDispatcher()
 {
   Disconnect();
 }
 
 // QueryInterface implementation for nsXULCommandDispatcher
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -52,17 +52,17 @@
 #include "nsGkAtoms.h"
 #include "nsContentUtils.h"
 #include "nsAttrName.h"
 #include "nsXMLContentSink.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsContentTypeParser.h"
 
-static PRLogModuleInfo* gContentSinkLog;
+static mozilla::LazyLogModule gContentSinkLog("nsXULContentSink");;
 
 //----------------------------------------------------------------------
 
 XULContentSinkImpl::ContextStack::ContextStack()
     : mTop(nullptr), mDepth(0)
 {
 }
 
@@ -157,19 +157,16 @@ XULContentSinkImpl::ContextStack::Traver
 
 XULContentSinkImpl::XULContentSinkImpl()
     : mText(nullptr),
       mTextLength(0),
       mTextSize(0),
       mConstrainSize(true),
       mState(eInProlog)
 {
-
-    if (! gContentSinkLog)
-        gContentSinkLog = PR_NewLogModule("nsXULContentSink");
 }
 
 
 XULContentSinkImpl::~XULContentSinkImpl()
 {
     // The context stack _should_ be empty, unless something has gone wrong.
     NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
     mContextStack.Clear();
--- a/dom/xul/templates/nsContentTestNode.cpp
+++ b/dom/xul/templates/nsContentTestNode.cpp
@@ -11,17 +11,17 @@
 #include "nsIXULTemplateResult.h"
 #include "nsIXULTemplateBuilder.h"
 #include "nsXULTemplateQueryProcessorRDF.h"
 
 #include "mozilla/Logging.h"
 
 using mozilla::LogLevel;
 
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 
 nsContentTestNode::nsContentTestNode(nsXULTemplateQueryProcessorRDF* aProcessor,
                                      nsIAtom* aRefVariable)
     : TestNode(nullptr),
       mProcessor(aProcessor),
       mDocument(nullptr),
       mRefVariable(aRefVariable),
       mTag(nullptr)
--- a/dom/xul/templates/nsInstantiationNode.cpp
+++ b/dom/xul/templates/nsInstantiationNode.cpp
@@ -3,17 +3,17 @@
  * 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 "nsInstantiationNode.h"
 #include "nsTemplateRule.h"
 #include "nsXULTemplateQueryProcessorRDF.h"
 
 #include "mozilla/Logging.h"
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 
 nsInstantiationNode::nsInstantiationNode(nsXULTemplateQueryProcessorRDF* aProcessor,
                                          nsRDFQuery* aQuery)
         : mProcessor(aProcessor),
           mQuery(aQuery)
 {
     MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
            ("nsInstantiationNode[%p] query=%p", this, aQuery));
--- a/dom/xul/templates/nsRDFConInstanceTestNode.cpp
+++ b/dom/xul/templates/nsRDFConInstanceTestNode.cpp
@@ -11,17 +11,17 @@
 #include "nsRDFConInstanceTestNode.h"
 #include "nsResourceSet.h"
 
 #include "mozilla/Logging.h"
 #include "nsXULContentUtils.h"
 
 using mozilla::LogLevel;
 
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 
 static const char*
 TestToString(nsRDFConInstanceTestNode::Test aTest) {
     switch (aTest) {
     case nsRDFConInstanceTestNode::eFalse:    return "false";
     case nsRDFConInstanceTestNode::eTrue:     return "true";
     case nsRDFConInstanceTestNode::eDontCare: return "dontcare";
     }
--- a/dom/xul/templates/nsRDFConMemberTestNode.cpp
+++ b/dom/xul/templates/nsRDFConMemberTestNode.cpp
@@ -11,17 +11,17 @@
 #include "nsResourceSet.h"
 #include "nsString.h"
 #include "nsXULContentUtils.h"
 
 #include "mozilla/Logging.h"
 
 using mozilla::LogLevel;
 
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 
 nsRDFConMemberTestNode::nsRDFConMemberTestNode(TestNode* aParent,
                                                nsXULTemplateQueryProcessorRDF* aProcessor,
                                                nsIAtom *aContainerVariable,
                                                nsIAtom *aMemberVariable)
     : nsRDFTestNode(aParent),
       mProcessor(aProcessor),
       mContainerVariable(aContainerVariable),
--- a/dom/xul/templates/nsRDFPropertyTestNode.cpp
+++ b/dom/xul/templates/nsRDFPropertyTestNode.cpp
@@ -6,17 +6,17 @@
 #include "nsRDFPropertyTestNode.h"
 #include "nsString.h"
 #include "nsXULContentUtils.h"
 
 #include "mozilla/Logging.h"
 
 using mozilla::LogLevel;
 
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 #include "nsIRDFLiteral.h"
 
 nsRDFPropertyTestNode::nsRDFPropertyTestNode(TestNode* aParent,
                                              nsXULTemplateQueryProcessorRDF* aProcessor,
                                              nsIAtom* aSourceVariable,
                                              nsIRDFResource* aProperty,
                                              nsIAtom* aTargetVariable)
     : nsRDFTestNode(aParent),
--- a/dom/xul/templates/nsRuleNetwork.cpp
+++ b/dom/xul/templates/nsRuleNetwork.cpp
@@ -16,28 +16,28 @@
 
  */
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "plhash.h"
 
 #include "mozilla/Logging.h"
-extern PRLogModuleInfo* gXULTemplateLog;
 
 #include "nsString.h"
 #include "nsUnicharUtils.h"
 #include "nsXULContentUtils.h"
 
 #include "nsRuleNetwork.h"
 #include "nsXULTemplateResultSetRDF.h"
 #include "nsRDFConMemberTestNode.h"
 #include "nsRDFPropertyTestNode.h"
 
 using namespace mozilla;
+extern LazyLogModule gXULTemplateLog;
 
 //----------------------------------------------------------------------
 //
 // nsRuleNetwork
 //
 
 nsresult
 MemoryElementSet::Add(MemoryElement* aElement)
--- a/dom/xul/templates/nsXULContentUtils.cpp
+++ b/dom/xul/templates/nsXULContentUtils.cpp
@@ -61,17 +61,17 @@
 using namespace mozilla;
 
 //------------------------------------------------------------------------
 
 nsIRDFService* nsXULContentUtils::gRDF;
 nsIDateTimeFormat* nsXULContentUtils::gFormat;
 nsICollation *nsXULContentUtils::gCollation;
 
-extern PRLogModuleInfo* gXULTemplateLog;
+extern LazyLogModule gXULTemplateLog;
 
 #define XUL_RESOURCE(ident, uri) nsIRDFResource* nsXULContentUtils::ident
 #define XUL_LITERAL(ident, val) nsIRDFLiteral* nsXULContentUtils::ident
 #include "nsXULResourceList.h"
 #undef XUL_RESOURCE
 #undef XUL_LITERAL
 
 //------------------------------------------------------------------------
--- a/dom/xul/templates/nsXULTemplateBuilder.cpp
+++ b/dom/xul/templates/nsXULTemplateBuilder.cpp
@@ -81,17 +81,17 @@ using namespace mozilla;
 
 nsrefcnt                  nsXULTemplateBuilder::gRefCnt = 0;
 nsIRDFService*            nsXULTemplateBuilder::gRDFService;
 nsIRDFContainerUtils*     nsXULTemplateBuilder::gRDFContainerUtils;
 nsIScriptSecurityManager* nsXULTemplateBuilder::gScriptSecurityManager;
 nsIPrincipal*             nsXULTemplateBuilder::gSystemPrincipal;
 nsIObserverService*       nsXULTemplateBuilder::gObserverService;
 
-PRLogModuleInfo* gXULTemplateLog;
+LazyLogModule gXULTemplateLog("nsXULTemplateBuilder");
 
 #define NS_QUERY_PROCESSOR_CONTRACTID_PREFIX "@mozilla.org/xul/xul-query-processor;1?name="
 
 //----------------------------------------------------------------------
 //
 // nsXULTemplateBuilder methods
 //
 
@@ -160,19 +160,16 @@ nsXULTemplateBuilder::InitGlobals()
         if (NS_FAILED(rv))
             return rv;
 
         rv = CallGetService(NS_OBSERVERSERVICE_CONTRACTID, &gObserverService);
         if (NS_FAILED(rv))
             return rv;
     }
 
-    if (! gXULTemplateLog)
-        gXULTemplateLog = PR_NewLogModule("nsXULTemplateBuilder");
-
     return NS_OK;
 }
 
 void
 nsXULTemplateBuilder::StartObserving(nsIDocument* aDocument)
 {
     aDocument->AddObserver(this);
     mObservedDocument = aDocument;
--- a/dom/xul/templates/nsXULTemplateBuilder.h
+++ b/dom/xul/templates/nsXULTemplateBuilder.h
@@ -21,17 +21,17 @@
 #include "nsTArray.h"
 #include "nsDataHashtable.h"
 #include "nsTemplateRule.h"
 #include "nsTemplateMatch.h"
 #include "nsIXULTemplateQueryProcessor.h"
 #include "nsCycleCollectionParticipant.h"
 
 #include "mozilla/Logging.h"
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 
 class nsIContent;
 class nsIObserverService;
 class nsIRDFCompositeDataSource;
 
 /**
  * An object that translates an RDF graph into a presentation using a
  * set of rules.
--- a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
@@ -24,17 +24,17 @@
 #include "nsCOMArray.h"
 #include "nsString.h"
 #include "nsClassHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 
 #include "mozilla/Logging.h"
-extern PRLogModuleInfo* gXULTemplateLog;
+extern mozilla::LazyLogModule gXULTemplateLog;
 
 class nsIContent;
 class nsXULTemplateResultRDF;
 
 /**
  * An object that generates results from a query on an RDF graph
  */
 class nsXULTemplateQueryProcessorRDF final : public nsIXULTemplateQueryProcessor,