Bug 1219470 - Replace PRLogModuleInfo with LazyLogModule. r=roc
authorsajitk <sajitk@rocketmail.com>
Thu, 05 Nov 2015 23:35:03 +0100
changeset 271734 b50b417d69b6a5ebf857b8e515d47f45db145c8e
parent 271733 39c48954dd49bfa8745d261c3505f040ad908447
child 271735 27066ece22a9f79db7415eca2b1f66a7fa5c67c3
push id29650
push usercbook@mozilla.com
push dateMon, 09 Nov 2015 13:56:12 +0000
treeherdermozilla-central@e1ef2be156de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1219470
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 1219470 - Replace PRLogModuleInfo with LazyLogModule. r=roc
layout/base/AccessibleCaretLogger.cpp
layout/base/AccessibleCaretLogger.h
layout/base/LayoutLogging.cpp
layout/base/LayoutLogging.h
layout/base/SelectionCarets.cpp
layout/base/TouchCaret.cpp
layout/base/moz.build
layout/base/nsDocumentViewer.cpp
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/base/nsRefreshDriver.cpp
layout/generic/nsFlexContainerFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
layout/generic/nsPageFrame.cpp
layout/generic/nsPluginFrame.cpp
layout/generic/nsSimplePageSequenceFrame.cpp
layout/printing/nsPrintData.cpp
layout/printing/nsPrintEngine.cpp
layout/style/Loader.cpp
deleted file mode 100644
--- a/layout/base/AccessibleCaretLogger.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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 "AccessibleCaretLogger.h"
-
-namespace mozilla {
-
-PRLogModuleInfo*
-GetAccessibleCaretLog()
-{
-  static PRLogModuleInfo* log = nullptr;
-
-  if (!log) {
-    log = PR_NewLogModule("AccessibleCaret");
-  }
-
-  return log;
-}
-
-} // namespace mozilla
--- a/layout/base/AccessibleCaretLogger.h
+++ b/layout/base/AccessibleCaretLogger.h
@@ -6,22 +6,22 @@
 
 #ifndef AccessibleCaretLog_h
 #define AccessibleCaretLog_h
 
 #include "mozilla/Logging.h"
 
 namespace mozilla {
 
-PRLogModuleInfo* GetAccessibleCaretLog();
+static LazyLogModule sAccessibleCaretLog("AccessibleCaret");
 
 #ifndef AC_LOG_BASE
-#define AC_LOG_BASE(...) MOZ_LOG(GetAccessibleCaretLog(), mozilla::LogLevel::Debug, (__VA_ARGS__));
+#define AC_LOG_BASE(...) MOZ_LOG(sAccessibleCaretLog, mozilla::LogLevel::Debug, (__VA_ARGS__));
 #endif
 
 #ifndef AC_LOGV_BASE
 #define AC_LOGV_BASE(...)                                                      \
-  MOZ_LOG(GetAccessibleCaretLog(), LogLevel::Verbose, (__VA_ARGS__));
+  MOZ_LOG(sAccessibleCaretLog, LogLevel::Verbose, (__VA_ARGS__));
 #endif
 
 } // namespace mozilla
 
 #endif // AccessibleCaretLog_h
--- a/layout/base/LayoutLogging.cpp
+++ b/layout/base/LayoutLogging.cpp
@@ -3,40 +3,30 @@
  * 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/. */
 
 // Chromium headers must come before Mozilla headers.
 #include "base/process_util.h"
 
 #include "LayoutLogging.h"
 
-PRLogModuleInfo* GetLayoutLog()
-{
-  static PRLogModuleInfo* log = nullptr;
-  if (!log) {
-    log = PR_NewLogModule("layout");
-  }
-
-  return log;
-}
-
 namespace mozilla {
 namespace detail {
 
 void LayoutLogWarning(const char* aStr, const char* aExpr,
                       const char* aFile, int32_t aLine)
 {
   if (aExpr) {
-    MOZ_LOG(GetLayoutLog(),
+    MOZ_LOG(sLayoutLog,
             mozilla::LogLevel::Warning,
             ("[%d] WARNING: %s: '%s', file %s, line %d",
              base::GetCurrentProcId(),
              aStr, aExpr, aFile, aLine));
   } else {
-    MOZ_LOG(GetLayoutLog(),
+    MOZ_LOG(sLayoutLog,
             mozilla::LogLevel::Warning,
             ("[%d] WARNING: %s: file %s, line %d",
              base::GetCurrentProcId(),
              aStr, aFile, aLine));
   }
 }
 
 } // namespace detail
--- a/layout/base/LayoutLogging.h
+++ b/layout/base/LayoutLogging.h
@@ -6,28 +6,28 @@
 #ifndef LayoutLogging_h
 #define LayoutLogging_h
 
 #include "mozilla/Logging.h"
 
 /**
  * Retrieves the log module to use for layout logging.
  */
-PRLogModuleInfo* GetLayoutLog();
+static mozilla::LazyLogModule sLayoutLog("layout");
 
 /**
  * Use the layout log to warn if a given condition is false.
  *
  * This is only enabled in debug builds and the logging is only displayed if
  * the environmental variable NSPR_LOG_MODULES includes "layout:2" (or higher).
  */
 #ifdef DEBUG
 #define LAYOUT_WARN_IF_FALSE(_cond, _msg)                                  \
   PR_BEGIN_MACRO                                                           \
-    if (MOZ_LOG_TEST(GetLayoutLog(), mozilla::LogLevel::Warning) &&        \
+    if (MOZ_LOG_TEST(sLayoutLog, mozilla::LogLevel::Warning) &&        \
         !(_cond)) {                                                        \
       mozilla::detail::LayoutLogWarning(_msg, #_cond, __FILE__, __LINE__); \
     }                                                                      \
   PR_END_MACRO
 #else
 #define LAYOUT_WARN_IF_FALSE(_cond, _msg) \
   PR_BEGIN_MACRO                          \
   PR_END_MACRO
@@ -37,17 +37,17 @@ PRLogModuleInfo* GetLayoutLog();
  * Use the layout log to emit a warning with the same format as NS_WARNING.
  *
  * This is only enabled in debug builds and the logging is only displayed if
  * the environmental variable NSPR_LOG_MODULES includes "layout:2" (or higher).
  */
 #ifdef DEBUG
 #define LAYOUT_WARNING(_msg)                                                \
   PR_BEGIN_MACRO                                                            \
-    if (MOZ_LOG_TEST(GetLayoutLog(), mozilla::LogLevel::Warning)) {         \
+    if (MOZ_LOG_TEST(sLayoutLog, mozilla::LogLevel::Warning)) {         \
       mozilla::detail::LayoutLogWarning(_msg, nullptr, __FILE__, __LINE__); \
     }                                                                       \
   PR_END_MACRO
 #else
 #define LAYOUT_WARNING(_msg) \
   PR_BEGIN_MACRO             \
   PR_END_MACRO
 #endif
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -35,18 +35,18 @@
 #include "mozilla/TouchEvents.h"
 #include "Layers.h"
 #include "TouchCaret.h"
 #include "nsFrameSelection.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
-static PRLogModuleInfo* gSelectionCaretsLog;
 static const char* kSelectionCaretsLogModuleName = "SelectionCarets";
+static mozilla::LazyLogModule gSelectionCaretsLog(kSelectionCaretsLogModuleName);
 
 // To enable all the SELECTIONCARETS_LOG print statements, set the environment
 // variable NSPR_LOG_MODULES=SelectionCarets:5
 #define SELECTIONCARETS_LOG(message, ...)                                      \
   MOZ_LOG(gSelectionCaretsLog, LogLevel::Debug,                                    \
          ("SelectionCarets (%p): %s:%d : " message "\n", this, __FUNCTION__,   \
           __LINE__, ##__VA_ARGS__));
 
@@ -80,20 +80,16 @@ SelectionCarets::SelectionCarets(nsIPres
   , mEndCaretVisible(false)
   , mStartCaretVisible(false)
   , mSelectionVisibleInScrollFrames(true)
   , mVisible(false)
   , mActionBarViewID(0)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (!gSelectionCaretsLog) {
-    gSelectionCaretsLog = PR_NewLogModule(kSelectionCaretsLogModuleName);
-  }
-
   SELECTIONCARETS_LOG("Constructor, PresShell=%p", mPresShell);
 
   static bool addedPref = false;
   if (!addedPref) {
     Preferences::AddIntVarCache(&sSelectionCaretsInflateSize,
                                 "selectioncaret.inflatesize.threshold");
     Preferences::AddBoolVarCache(&sSelectionCaretDetectsLongTap,
                                  "selectioncaret.detects.longtap", true);
--- a/layout/base/TouchCaret.cpp
+++ b/layout/base/TouchCaret.cpp
@@ -31,18 +31,18 @@
 #include "nsView.h"
 #include "mozilla/dom/SelectionStateChangedEvent.h"
 #include "mozilla/dom/CustomEvent.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
-static PRLogModuleInfo* gTouchCaretLog;
 static const char* kTouchCaretLogModuleName = "TouchCaret";
+static mozilla::LazyLogModule gTouchCaretLog(kTouchCaretLogModuleName);
 
 // To enable all the TOUCHCARET_LOG print statements, set the environment
 // variable NSPR_LOG_MODULES=TouchCaret:5
 #define TOUCHCARET_LOG(message, ...)                                           \
   MOZ_LOG(gTouchCaretLog, LogLevel::Debug,                                         \
          ("TouchCaret (%p): %s:%d : " message "\n", this, __FUNCTION__,        \
           __LINE__, ##__VA_ARGS__));
 
@@ -74,20 +74,16 @@ TouchCaret::TouchCaret(nsIPresShell* aPr
     mCaretCenterToDownPointOffsetY(0),
     mInAsyncPanZoomGesture(false),
     mVisible(false),
     mIsValidTap(false),
     mActionBarViewID(0)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (!gTouchCaretLog) {
-    gTouchCaretLog = PR_NewLogModule(kTouchCaretLogModuleName);
-  }
-
   TOUCHCARET_LOG("Constructor, PresShell=%p", aPresShell);
 
   static bool addedTouchCaretPref = false;
   if (!addedTouchCaretPref) {
     Preferences::AddIntVarCache(&sTouchCaretInflateSize,
                                 "touchcaret.inflatesize.threshold");
     Preferences::AddIntVarCache(&sTouchCaretExpirationTime,
                                 "touchcaret.expiration.time");
--- a/layout/base/moz.build
+++ b/layout/base/moz.build
@@ -105,17 +105,16 @@ EXPORTS.mozilla += [
     'GeometryUtils.h',
     'PaintTracker.h',
     'RestyleLogging.h',
 ]
 
 UNIFIED_SOURCES += [
     'AccessibleCaret.cpp',
     'AccessibleCaretEventHub.cpp',
-    'AccessibleCaretLogger.cpp',
     'AccessibleCaretManager.cpp',
     'ActiveLayerTracker.cpp',
     'DisplayItemClip.cpp',
     'DisplayListClipState.cpp',
     'FrameLayerBuilder.cpp',
     'FramePropertyTable.cpp',
     'GeometryUtils.cpp',
     'LayoutLogging.cpp',
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -131,25 +131,19 @@ using namespace mozilla::dom;
 #define BEFOREUNLOAD_REQUIRES_INTERACTION_PREFNAME "dom.require_user_interaction_for_beforeunload"
 
 //-----------------------------------------------------
 // LOGGING
 #include "LayoutLogging.h"
 #include "mozilla/Logging.h"
 
 #ifdef NS_PRINTING
-static PRLogModuleInfo *
-GetPrintingLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("printing");
-  return sLog;
-}
-#define PR_PL(_p1)  MOZ_LOG(GetPrintingLog(), mozilla::LogLevel::Debug, _p1);
+static mozilla::LazyLogModule gPrintingLog("printing");
+
+#define PR_PL(_p1)  MOZ_LOG(gPrintingLog, mozilla::LogLevel::Debug, _p1);
 #endif // NS_PRINTING
 
 #define PRT_YESNO(_p) ((_p)?"YES":"NO")
 //-----------------------------------------------------
 
 class nsDocumentViewer;
 class nsPrintEventDispatcher;
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -531,17 +531,17 @@ public:
   }
 
 private:
   nsCOMPtr<nsIDocument> mDocument;
 };
 
 bool PresShell::sDisableNonTestMouseEvents = false;
 
-PRLogModuleInfo* PresShell::gLog;
+mozilla::LazyLogModule PresShell::gLog("PresShell");
 
 #ifdef DEBUG
 static void
 VerifyStyleTree(nsPresContext* aPresContext, nsFrameManager* aFrameManager)
 {
   if (nsFrame::GetVerifyStyleTreeEnable()) {
     nsIFrame* rootFrame = aFrameManager->GetRootFrame();
     aPresContext->RestyleManager()->DebugVerifyStyleTree(rootFrame);
@@ -759,19 +759,17 @@ PresShell::PresShell()
   : mMouseLocation(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)
 {
 #ifdef MOZ_REFLOW_PERF
   mReflowCountMgr = new ReflowCountMgr();
   mReflowCountMgr->SetPresContext(mPresContext);
   mReflowCountMgr->SetPresShell(this);
 #endif
   mLoadBegin = TimeStamp::Now();
-  if (!gLog) {
-    gLog = PR_NewLogModule("PresShell");
-  }
+
   mSelectionFlags = nsISelectionDisplay::DISPLAY_TEXT | nsISelectionDisplay::DISPLAY_IMAGES;
   mIsThemeSupportDisabled = false;
   mIsActive = true;
   // FIXME/bug 735029: find a better solution to this problem
 #ifdef MOZ_WIDGET_ANDROID
   // The java pan/zoom code uses this to mean approximately "request a
   // reset of pan/zoom state" which doesn't necessarily correspond
   // with the first paint of content.
@@ -2460,17 +2458,17 @@ PresShell::BeginLoad(nsIDocument *aDocum
 {
   mDocumentLoading = true;
 
   gfxTextPerfMetrics *tp = nullptr;
   if (mPresContext) {
     tp = mPresContext->GetTextPerfMetrics();
   }
 
-  bool shouldLog = gLog && MOZ_LOG_TEST(gLog, LogLevel::Debug);
+  bool shouldLog = MOZ_LOG_TEST(gLog, LogLevel::Debug);
   if (shouldLog || tp) {
     mLoadBegin = TimeStamp::Now();
   }
 
   if (shouldLog) {
     nsIURI* uri = mDocument->GetDocumentURI();
     nsAutoCString spec;
     if (uri) {
@@ -2496,17 +2494,17 @@ void
 PresShell::LoadComplete()
 {
   gfxTextPerfMetrics *tp = nullptr;
   if (mPresContext) {
     tp = mPresContext->GetTextPerfMetrics();
   }
 
   // log load
-  bool shouldLog = gLog && MOZ_LOG_TEST(gLog, LogLevel::Debug);
+  bool shouldLog = MOZ_LOG_TEST(gLog, LogLevel::Debug);
   if (shouldLog || tp) {
     TimeDuration loadTime = TimeStamp::Now() - mLoadBegin;
     nsIURI* uri = mDocument->GetDocumentURI();
     nsAutoCString spec;
     if (uri) {
       uri->GetSpec(spec);
     }
     if (shouldLog) {
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -330,17 +330,17 @@ public:
 #ifdef DEBUG
   virtual void ListStyleContexts(nsIFrame *aRootFrame, FILE *out,
                                  int32_t aIndent = 0) override;
 
   virtual void ListStyleSheets(FILE *out, int32_t aIndent = 0) override;
   virtual void VerifyStyleTree() override;
 #endif
 
-  static PRLogModuleInfo* gLog;
+  static mozilla::LazyLogModule gLog;
 
   virtual void DisableNonTestMouseEvents(bool aDisable) override;
 
   virtual void UpdateCanvasBackground() override;
 
   virtual void AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
                                             nsDisplayList& aList,
                                             nsIFrame* aFrame,
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -70,18 +70,18 @@
 #include "ipc/Nuwa.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::widget;
 using namespace mozilla::ipc;
 using namespace mozilla::layout;
 
-static PRLogModuleInfo *gLog = nullptr;
-#define LOG(...) MOZ_LOG(gLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
+static mozilla::LazyLogModule sRefreshDriverLog("nsRefreshDriver");
+#define LOG(...) MOZ_LOG(sRefreshDriverLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
 
 #define DEFAULT_THROTTLED_FRAME_RATE 1
 #define DEFAULT_RECOMPUTE_VISIBILITY_INTERVAL_MS 1000
 // after 10 minutes, stop firing off inactive timers
 #define DEFAULT_INACTIVE_TIMER_DISABLE_SECONDS 600
 
 namespace mozilla {
 
@@ -766,19 +766,16 @@ GetFirstFrameDelay(imgIRequest* req)
     return 0;
 
   return static_cast<uint32_t>(delay);
 }
 
 /* static */ void
 nsRefreshDriver::InitializeStatics()
 {
-  if (!gLog) {
-    gLog = PR_NewLogModule("nsRefreshDriver");
-  }
 }
 
 /* static */ void
 nsRefreshDriver::Shutdown()
 {
   // clean up our timers
   delete sRegularRateTimer;
   delete sThrottledRateTimer;
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -28,24 +28,17 @@ using namespace mozilla::layout;
 
 // Convenience typedefs for helper classes that we forward-declare in .h file
 // (so that nsFlexContainerFrame methods can use them as parameters):
 typedef nsFlexContainerFrame::FlexItem FlexItem;
 typedef nsFlexContainerFrame::FlexLine FlexLine;
 typedef nsFlexContainerFrame::FlexboxAxisTracker FlexboxAxisTracker;
 typedef nsFlexContainerFrame::StrutInfo StrutInfo;
 
-static PRLogModuleInfo*
-GetFlexContainerLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("nsFlexContainerFrame");
-  return sLog;
-}
+static mozilla::LazyLogModule gFlexContainerLog("nsFlexContainerFrame");
 
 // XXXdholbert Some of this helper-stuff should be separated out into a general
 // "main/cross-axis utils" header, shared by grid & flexbox?
 // (Particularly when grid gets support for align-*/justify-* properties.)
 
 // Helper enums
 // ============
 
@@ -2152,17 +2145,17 @@ FlexLine::FreezeOrRestoreEachFlexibleSiz
       item->ClearViolationFlags();
     }
   }
 }
 
 void
 FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize)
 {
-  MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug, ("ResolveFlexibleLengths\n"));
+  MOZ_LOG(gFlexContainerLog, LogLevel::Debug, ("ResolveFlexibleLengths\n"));
 
   // Determine whether we're going to be growing or shrinking items.
   const bool isUsingFlexGrow =
     (mTotalOuterHypotheticalMainSize < aFlexContainerMainSize);
 
   // Do an "early freeze" for flex items that obviously can't flex in the
   // direction we've chosen:
   FreezeItemsEarly(isUsingFlexGrow);
@@ -2200,17 +2193,17 @@ FlexLine::ResolveFlexibleLengths(nscoord
     nscoord availableFreeSpace = spaceAvailableForFlexItemsContentBoxes;
     for (FlexItem* item = mItems.getFirst(); item; item = item->getNext()) {
       if (!item->IsFrozen()) {
         item->SetMainSize(item->GetFlexBaseSize());
       }
       availableFreeSpace -= item->GetMainSize();
     }
 
-    MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug,
+    MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
            (" available free space = %d\n", availableFreeSpace));
 
 
     // The sign of our free space should agree with the type of flexing
     // (grow/shrink) that we're doing (except if we've had integer overflow;
     // then, all bets are off). Any disagreement should've made us use the
     // other type of flexing, or should've been resolved in FreezeItemsEarly.
     // XXXdholbert If & when bug 765861 is fixed, we should upgrade this
@@ -2312,17 +2305,17 @@ FlexLine::ResolveFlexibleLengths(nscoord
             availableFreeSpace = std::min(availableFreeSpace,
                                           totalDesiredPortionOfOrigFreeSpace);
           } else {
             availableFreeSpace = std::max(availableFreeSpace,
                                           totalDesiredPortionOfOrigFreeSpace);
           }
         }
 
-        MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug,
+        MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
                (" Distributing available space:"));
         // Since this loop only operates on unfrozen flex items, we can break as
         // soon as we have seen all of them.
         numUnfrozenItemsToBeSeen = mNumItems - mNumFrozenItems;
 
         // NOTE: It's important that we traverse our items in *reverse* order
         // here, for correct width distribution according to the items'
         // "ShareOfWeightSoFar" progressively-calculated values.
@@ -2360,27 +2353,27 @@ FlexLine::ResolveFlexibleLengths(nscoord
                 NSToCoordRound(availableFreeSpace /
                                float(numItemsWithLargestWeight));
               numItemsWithLargestWeight--;
             }
 
             availableFreeSpace -= sizeDelta;
 
             item->SetMainSize(item->GetMainSize() + sizeDelta);
-            MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug,
+            MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
                    ("  child %p receives %d, for a total of %d\n",
                     item, sizeDelta, item->GetMainSize()));
           }
         }
       }
     }
 
     // Fix min/max violations:
     nscoord totalViolation = 0; // keeps track of adjustments for min/max
-    MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug,
+    MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
            (" Checking for violations:"));
 
     // Since this loop only operates on unfrozen flex items, we can break as
     // soon as we have seen all of them.
     uint32_t numUnfrozenItemsToBeSeen = mNumItems - mNumFrozenItems;
     for (FlexItem* item = mItems.getFirst();
          numUnfrozenItemsToBeSeen > 0; item = item->getNext()) {
       MOZ_ASSERT(item, "numUnfrozenItemsToBeSeen says items remain to be seen");
@@ -2399,17 +2392,17 @@ FlexLine::ResolveFlexibleLengths(nscoord
           item->SetHadMaxViolation();
         }
       }
     }
 
     FreezeOrRestoreEachFlexibleSize(totalViolation,
                                     iterationCounter + 1 == mNumItems);
 
-    MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug,
+    MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
            (" Total violation: %d\n", totalViolation));
 
     if (mNumFrozenItems == mNumItems) {
       break;
     }
 
     MOZ_ASSERT(totalViolation != 0,
                "Zero violation should've made us freeze all items & break");
@@ -3606,17 +3599,17 @@ void
 nsFlexContainerFrame::Reflow(nsPresContext*           aPresContext,
                              nsHTMLReflowMetrics&     aDesiredSize,
                              const nsHTMLReflowState& aReflowState,
                              nsReflowStatus&          aStatus)
 {
   MarkInReflow();
   DO_GLOBAL_REFLOW_COUNT("nsFlexContainerFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
-  MOZ_LOG(GetFlexContainerLog(), LogLevel::Debug,
+  MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
          ("Reflow() for nsFlexContainerFrame %p\n", this));
 
   if (IsFrameTreeTooDeep(aReflowState, aDesiredSize, aStatus)) {
     return;
   }
 
   // We (and our children) can only depend on our ancestor's bsize if we have
   // a percent-bsize, or if we're positioned and we have "block-start" and "block-end"
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -209,49 +209,37 @@ bool nsFrame::GetShowEventTargetFrameBor
 {
   return gShowEventTargetFrameBorder;
 }
 
 /**
  * Note: the log module is created during library initialization which
  * means that you cannot perform logging before then.
  */
-static PRLogModuleInfo* gLogModule;
-
-static PRLogModuleInfo* gStyleVerifyTreeLogModuleInfo;
+mozilla::LazyLogModule nsFrame::sFrameLogModule("frame");
+
+static mozilla::LazyLogModule sStyleVerifyTreeLogModuleInfo("styleverifytree");
 
 static uint32_t gStyleVerifyTreeEnable = 0x55;
 
 bool
 nsFrame::GetVerifyStyleTreeEnable()
 {
   if (gStyleVerifyTreeEnable == 0x55) {
-    if (nullptr == gStyleVerifyTreeLogModuleInfo) {
-      gStyleVerifyTreeLogModuleInfo = PR_NewLogModule("styleverifytree");
-      gStyleVerifyTreeEnable = 0 != gStyleVerifyTreeLogModuleInfo->level;
-    }
+      gStyleVerifyTreeEnable = 0 != (int)((mozilla::LogModule*)sStyleVerifyTreeLogModuleInfo)->Level();
   }
   return gStyleVerifyTreeEnable;
 }
 
 void
 nsFrame::SetVerifyStyleTreeEnable(bool aEnabled)
 {
   gStyleVerifyTreeEnable = aEnabled;
 }
 
-PRLogModuleInfo*
-nsFrame::GetLogModuleInfo()
-{
-  if (nullptr == gLogModule) {
-    gLogModule = PR_NewLogModule("frame");
-  }
-  return gLogModule;
-}
-
 #endif
 
 NS_DECLARE_FRAME_PROPERTY(AbsoluteContainingBlockProperty,
                           DeleteValue<nsAbsoluteContainingBlock>)
 
 bool
 nsIFrame::HasAbsolutelyPositionedChildren() const {
   return IsAbsoluteContainer() && GetAbsoluteContainingBlock()->HasAbsoluteFrames();
@@ -9138,40 +9126,40 @@ GetTagName(nsFrame* aFrame, nsIContent* 
   else {
     PR_snprintf(aResult, aResultSize, "@%p", aFrame);
   }
 }
 
 void
 nsFrame::Trace(const char* aMethod, bool aEnter)
 {
-  if (NS_FRAME_LOG_TEST(GetLogModuleInfo(), NS_FRAME_TRACE_CALLS)) {
+  if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)) {
     char tagbuf[40];
     GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
     PR_LogPrint("%s: %s %s", tagbuf, aEnter ? "enter" : "exit", aMethod);
   }
 }
 
 void
 nsFrame::Trace(const char* aMethod, bool aEnter, nsReflowStatus aStatus)
 {
-  if (NS_FRAME_LOG_TEST(GetLogModuleInfo(), NS_FRAME_TRACE_CALLS)) {
+  if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)) {
     char tagbuf[40];
     GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
     PR_LogPrint("%s: %s %s, status=%scomplete%s",
                 tagbuf, aEnter ? "enter" : "exit", aMethod,
                 NS_FRAME_IS_NOT_COMPLETE(aStatus) ? "not" : "",
                 (NS_FRAME_REFLOW_NEXTINFLOW & aStatus) ? "+reflow" : "");
   }
 }
 
 void
 nsFrame::TraceMsg(const char* aFormatString, ...)
 {
-  if (NS_FRAME_LOG_TEST(GetLogModuleInfo(), NS_FRAME_TRACE_CALLS)) {
+  if (NS_FRAME_LOG_TEST(sFrameLogModule, NS_FRAME_TRACE_CALLS)) {
     // Format arguments into a buffer
     char argbuf[200];
     va_list ap;
     va_start(ap, aFormatString);
     PR_vsnprintf(argbuf, sizeof(argbuf), aFormatString, ap);
     va_end(ap);
 
     char tagbuf[40];
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -25,46 +25,46 @@
  * specific type of logging. Each logging operation has associated
  * inline methods defined below.
  */
 #define NS_FRAME_TRACE_CALLS        0x1
 #define NS_FRAME_TRACE_PUSH_PULL    0x2
 #define NS_FRAME_TRACE_CHILD_REFLOW 0x4
 #define NS_FRAME_TRACE_NEW_FRAMES   0x8
 
-#define NS_FRAME_LOG_TEST(_lm,_bit) (int((_lm)->level) & (_bit))
+#define NS_FRAME_LOG_TEST(_lm,_bit) (int(((mozilla::LogModule*)_lm)->Level()) & (_bit))
 
 #ifdef DEBUG
 #define NS_FRAME_LOG(_bit,_args)                                \
   PR_BEGIN_MACRO                                                \
-    if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) {  \
+    if (NS_FRAME_LOG_TEST(nsFrame::sFrameLogModule,_bit)) {  \
       PR_LogPrint _args;                                        \
     }                                                           \
   PR_END_MACRO
 #else
 #define NS_FRAME_LOG(_bit,_args)
 #endif
 
 // XXX Need to rework this so that logging is free when it's off
 #ifdef DEBUG
 #define NS_FRAME_TRACE_IN(_method) Trace(_method, true)
 
 #define NS_FRAME_TRACE_OUT(_method) Trace(_method, false)
 
 // XXX remove me
 #define NS_FRAME_TRACE_MSG(_bit,_args)                          \
   PR_BEGIN_MACRO                                                \
-    if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) {  \
+    if (NS_FRAME_LOG_TEST(nsFrame::sFrameLogModule,_bit)) {  \
       TraceMsg _args;                                           \
     }                                                           \
   PR_END_MACRO
 
 #define NS_FRAME_TRACE(_bit,_args)                              \
   PR_BEGIN_MACRO                                                \
-    if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) {  \
+    if (NS_FRAME_LOG_TEST(nsFrame::sFrameLogModule,_bit)) {  \
       TraceMsg _args;                                           \
     }                                                           \
   PR_END_MACRO
 
 #define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, true)
 
 #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \
   Trace(_method, false, _status)
@@ -718,24 +718,17 @@ public:
    */
   static bool GetVerifyStyleTreeEnable();
 
   /**
    * Set the verify-style-tree enable flag.
    */
   static void SetVerifyStyleTreeEnable(bool aEnabled);
 
-  /**
-   * The frame class and related classes share an nspr log module
-   * for logging frame activity.
-   *
-   * Note: the log module is created during library initialization which
-   * means that you cannot perform logging before then.
-   */
-  static PRLogModuleInfo* GetLogModuleInfo();
+  static mozilla::LazyLogModule sFrameLogModule;
 
   // Show frame borders when rendering
   static void ShowFrameBorders(bool aEnable);
   static bool GetShowFrameBorders();
 
   // Show frame border of event target
   static void ShowEventTargetFrameBorder(bool aEnable);
   static bool GetShowEventTargetFrameBorder();
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -17,18 +17,18 @@
 #include "nsDisplayList.h"
 #include "nsLayoutUtils.h" // for function BinarySearchForPosition
 #include "nsSimplePageSequenceFrame.h" // for nsSharedPageData
 #include "nsTextFormatter.h" // for page number localization formatting
 #include "nsBidiUtils.h"
 #include "nsIPrintSettings.h"
 
 #include "mozilla/Logging.h"
-extern PRLogModuleInfo *GetLayoutPrintingLog();
-#define PR_PL(_p1)  MOZ_LOG(GetLayoutPrintingLog(), mozilla::LogLevel::Debug, _p1)
+extern mozilla::LazyLogModule gLayoutPrintingLog;
+#define PR_PL(_p1)  MOZ_LOG(gLayoutPrintingLog, mozilla::LogLevel::Debug, _p1)
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 nsPageFrame*
 NS_NewPageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsPageFrame(aContext);
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -89,24 +89,17 @@ using mozilla::DefaultXDisplay;
 #endif
 
 #include "mozilla/dom/TabChild.h"
 
 #ifdef CreateEvent // Thank you MS.
 #undef CreateEvent
 #endif
 
-static PRLogModuleInfo *
-GetObjectFrameLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("nsPluginFrame");
-  return sLog;
-}
+static mozilla::LazyLogModule sPluginFrameLog("nsPluginFrame");
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 class PluginBackgroundSink : public ReadbackSink {
 public:
   PluginBackgroundSink(nsPluginFrame* aFrame, uint64_t aStartSequenceNumber)
@@ -155,23 +148,23 @@ protected:
 };
 
 nsPluginFrame::nsPluginFrame(nsStyleContext* aContext)
   : nsPluginFrameSuper(aContext)
   , mInstanceOwner(nullptr)
   , mReflowCallbackPosted(false)
   , mIsHiddenDueToScroll(false)
 {
-  MOZ_LOG(GetObjectFrameLog(), LogLevel::Debug,
+  MOZ_LOG(sPluginFrameLog, LogLevel::Debug,
          ("Created new nsPluginFrame %p\n", this));
 }
 
 nsPluginFrame::~nsPluginFrame()
 {
-  MOZ_LOG(GetObjectFrameLog(), LogLevel::Debug,
+  MOZ_LOG(sPluginFrameLog, LogLevel::Debug,
          ("nsPluginFrame %p deleted\n", this));
 }
 
 NS_QUERYFRAME_HEAD(nsPluginFrame)
   NS_QUERYFRAME_ENTRY(nsPluginFrame)
   NS_QUERYFRAME_ENTRY(nsIObjectFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsPluginFrameSuper)
 
@@ -191,17 +184,17 @@ NS_IMETHODIMP nsPluginFrame::GetPluginPo
 #endif
 #endif
 
 void
 nsPluginFrame::Init(nsIContent*       aContent,
                     nsContainerFrame* aParent,
                     nsIFrame*         aPrevInFlow)
 {
-  MOZ_LOG(GetObjectFrameLog(), LogLevel::Debug,
+  MOZ_LOG(sPluginFrameLog, LogLevel::Debug,
          ("Initializing nsPluginFrame %p for content %p\n", this, aContent));
 
   nsPluginFrameSuper::Init(aContent, aParent, aPrevInFlow);
 }
 
 void
 nsPluginFrame::DestroyFrom(nsIFrame* aDestructRoot)
 {
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -37,25 +37,19 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1";
 
 //
 
 #include "mozilla/Logging.h"
-PRLogModuleInfo *
-GetLayoutPrintingLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("printing-layout");
-  return sLog;
-}
-#define PR_PL(_p1)  MOZ_LOG(GetLayoutPrintingLog(), mozilla::LogLevel::Debug, _p1)
+mozilla::LazyLogModule gLayoutPrintingLog("printing-layout");
+
+#define PR_PL(_p1)  MOZ_LOG(gLayoutPrintingLog, mozilla::LogLevel::Debug, _p1)
 
 nsSimplePageSequenceFrame*
 NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsSimplePageSequenceFrame(aContext);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSimplePageSequenceFrame)
--- a/layout/printing/nsPrintData.cpp
+++ b/layout/printing/nsPrintData.cpp
@@ -12,25 +12,19 @@
 #include "nsIWebProgressListener.h"
 #include "mozilla/Services.h"
 
 //-----------------------------------------------------
 // PR LOGGING
 #include "mozilla/Logging.h"
 
 #define DUMP_LAYOUT_LEVEL 9 // this turns on the dumping of each doucment's layout info
-static PRLogModuleInfo *
-GetPrintingLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("printing");
-  return sLog;
-}
-#define PR_PL(_p1)  MOZ_LOG(GetPrintingLog(), mozilla::LogLevel::Debug, _p1);
+static mozilla::LazyLogModule gPrintingLog("printing");
+
+#define PR_PL(_p1)  MOZ_LOG(gPrintingLog, mozilla::LogLevel::Debug, _p1);
 
 //---------------------------------------------------
 //-- nsPrintData Class Impl
 //---------------------------------------------------
 nsPrintData::nsPrintData(ePrintDataType aType) :
   mType(aType), mDebugFilePtr(nullptr), mPrintObject(nullptr), mSelectedPO(nullptr),
   mPrintDocList(0), mIsIFrameSelected(false),
   mIsParentAFrameSet(false), mOnStartSent(false),
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -135,25 +135,19 @@ using namespace mozilla::dom;
 // PR_LOGGING is force to always be on (even in release builds)
 // but we only want some of it on,
 //#define EXTENDED_DEBUG_PRINTING 
 #endif
 
 #define DUMP_LAYOUT_LEVEL 9 // this turns on the dumping of each doucment's layout info
 
 #ifndef PR_PL
-static PRLogModuleInfo *
-GetPrintingLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("printing");
-  return sLog;
-}
-#define PR_PL(_p1)  MOZ_LOG(GetPrintingLog(), mozilla::LogLevel::Debug, _p1);
+static mozilla::LazyLogModule gPrintingLog("printing")
+
+#define PR_PL(_p1)  MOZ_LOG(gPrintingLog, mozilla::LogLevel::Debug, _p1);
 #endif
 
 #ifdef EXTENDED_DEBUG_PRINTING
 static uint32_t gDumpFileNameCnt   = 0;
 static uint32_t gDumpLOFileNameCnt = 0;
 #endif
 
 #define PRT_YESNO(_p) ((_p)?"YES":"NO")
@@ -1639,17 +1633,17 @@ nsPrintEngine::SetupToPrintContent()
     }
 
     if (mPrt->mShrinkRatio < 0.998f) {
       rv = ReconstructAndReflow(true);
       didReconstruction = true;
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    if (MOZ_LOG_TEST(GetPrintingLog(), LogLevel::Debug)) {
+    if (MOZ_LOG_TEST(gPrintingLog, LogLevel::Debug)) {
       float calcRatio = 0.0f;
       if (mPrt->mPrintDocList.Length() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
         nsPrintObject* smallestPO = FindSmallestSTF();
         NS_ASSERTION(smallestPO, "There must always be an XMost PO!");
         if (smallestPO) {
           // Calc the shrinkage based on the entire content area
           calcRatio = smallestPO->mShrinkRatio;
         }
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -261,43 +261,28 @@ public:
   nsresult                              mStatus;
 
 private:
   void FireLoadEvent(nsIThreadInternal* aThread);
 };
 
 #include "mozilla/Logging.h"
 
-static PRLogModuleInfo *
-GetLoaderLog()
-{
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("nsCSSLoader");
-  return sLog;
-}
+static mozilla::LazyLogModule sCssLoaderLog("nsCSSLoader");
+
+static mozilla::LazyLogModule gSriPRLog("SRI");
 
-static PRLogModuleInfo*
-GetSriLog()
-{
-  static PRLogModuleInfo *gSriPRLog;
-  if (!gSriPRLog) {
-    gSriPRLog = PR_NewLogModule("SRI");
-  }
-  return gSriPRLog;
-}
-
-#define LOG_ERROR(args) MOZ_LOG(GetLoaderLog(), mozilla::LogLevel::Error, args)
-#define LOG_WARN(args) MOZ_LOG(GetLoaderLog(), mozilla::LogLevel::Warning, args)
-#define LOG_DEBUG(args) MOZ_LOG(GetLoaderLog(), mozilla::LogLevel::Debug, args)
+#define LOG_ERROR(args) MOZ_LOG(sCssLoaderLog, mozilla::LogLevel::Error, args)
+#define LOG_WARN(args) MOZ_LOG(sCssLoaderLog, mozilla::LogLevel::Warning, args)
+#define LOG_DEBUG(args) MOZ_LOG(sCssLoaderLog, mozilla::LogLevel::Debug, args)
 #define LOG(args) LOG_DEBUG(args)
 
-#define LOG_ERROR_ENABLED() MOZ_LOG_TEST(GetLoaderLog(), mozilla::LogLevel::Error)
-#define LOG_WARN_ENABLED() MOZ_LOG_TEST(GetLoaderLog(), mozilla::LogLevel::Warning)
-#define LOG_DEBUG_ENABLED() MOZ_LOG_TEST(GetLoaderLog(), mozilla::LogLevel::Debug)
+#define LOG_ERROR_ENABLED() MOZ_LOG_TEST(sCssLoaderLog, mozilla::LogLevel::Error)
+#define LOG_WARN_ENABLED() MOZ_LOG_TEST(sCssLoaderLog, mozilla::LogLevel::Warning)
+#define LOG_DEBUG_ENABLED() MOZ_LOG_TEST(sCssLoaderLog, mozilla::LogLevel::Debug)
 #define LOG_ENABLED() LOG_DEBUG_ENABLED()
 
 #define LOG_URI(format, uri)                        \
   PR_BEGIN_MACRO                                    \
     NS_ASSERTION(uri, "Logging null uri");          \
     if (LOG_ENABLED()) {                            \
       nsAutoCString _logURISpec;                    \
       uri->GetSpec(_logURISpec);                    \
@@ -977,17 +962,17 @@ SheetLoadData::OnStreamComplete(nsIUnich
   }
 
   SRIMetadata sriMetadata = mSheet->GetIntegrity();
   if (!sriMetadata.IsEmpty() &&
       NS_FAILED(SRICheck::VerifyIntegrity(sriMetadata, aLoader,
                                           mSheet->GetCORSMode(), aBuffer,
                                           mLoader->mDocument))) {
     LOG(("  Load was blocked by SRI"));
-    MOZ_LOG(GetSriLog(), mozilla::LogLevel::Debug,
+    MOZ_LOG(gSriPRLog, mozilla::LogLevel::Debug,
             ("css::Loader::OnStreamComplete, bad metadata"));
     mLoader->SheetComplete(this, NS_ERROR_SRI_CORRUPT);
     return NS_OK;
   }
 
   // Enough to set the URIs on mSheet, since any sibling datas we have share
   // the same mInner as mSheet and will thus get the same URI.
   mSheet->SetURIs(channelURI, originalURI, channelURI);
@@ -1266,17 +1251,17 @@ Loader::CreateSheet(nsIURI* aURI,
     } else {
       baseURI = aURI;
       sheetURI = aURI;
       originalURI = aURI;
     }
 
     SRIMetadata sriMetadata;
     if (!aIntegrity.IsEmpty()) {
-      MOZ_LOG(GetSriLog(), mozilla::LogLevel::Debug,
+      MOZ_LOG(gSriPRLog, mozilla::LogLevel::Debug,
               ("css::Loader::CreateSheet, integrity=%s",
                NS_ConvertUTF16toUTF8(aIntegrity).get()));
       SRICheck::IntegrityMetadata(aIntegrity, mDocument, &sriMetadata);
     }
 
     RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(aCORSMode,
                                                       aReferrerPolicy,
                                                       sriMetadata);