From 5d881775b755f7b993fa1fe969316e80ed9f6347 Mon Sep 17 00:00:00 2001 From: sajitk Date: Thu, 28 Jan 2016 10:35:00 -0500 Subject: [PATCH] Bug 1219482 - Replace PRLogModuleInfo with LazyLogModule in various files. r=bsmedberg --- docshell/base/nsDocShell.cpp | 16 +++----------- docshell/shistory/nsSHistory.cpp | 17 +++++---------- extensions/auth/nsAuth.h | 2 +- extensions/auth/nsAuthFactory.cpp | 3 +-- extensions/gio/nsGIOProtocolHandler.cpp | 4 +--- .../pref/autoconfig/src/nsAutoConfig.cpp | 2 +- .../autoconfig/src/nsJSConfigTriggers.cpp | 2 +- .../pref/autoconfig/src/nsReadConfig.cpp | 4 +--- hal/Hal.cpp | 7 ++----- hal/HalLog.h | 2 +- ipc/chromium/src/base/logging.cc | 12 ++--------- ipc/chromium/src/base/logging.h | 4 ++-- js/xpconnect/loader/mozJSComponentLoader.cpp | 6 +----- js/xpconnect/src/XPCLog.cpp | 7 ++----- js/xpconnect/src/nsXPConnect.cpp | 15 +++++-------- modules/libjar/nsJARChannel.cpp | 5 +---- parser/htmlparser/nsExpatDriver.cpp | 21 +++++++------------ rdf/base/nsCompositeDataSource.cpp | 4 +--- rdf/base/nsInMemoryDataSource.cpp | 7 ++----- rdf/base/nsRDFContentSink.cpp | 7 ++----- rdf/base/nsRDFService.cpp | 5 +---- rdf/base/nsRDFXMLDataSource.cpp | 6 ++---- storage/VacuumManager.cpp | 2 +- storage/mozStorageAsyncStatement.cpp | 2 +- storage/mozStorageConnection.cpp | 5 +---- storage/mozStoragePrivateHelpers.cpp | 2 +- storage/mozStorageStatement.cpp | 2 +- 27 files changed, 50 insertions(+), 121 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 60edb8f31fdb2..c9f33499f10d0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -266,9 +266,9 @@ static uint32_t gValidateOrigin = 0xffffffff; #define NS_EVENT_STARVATION_DELAY_HINT 2000 #ifdef DEBUG -static PRLogModuleInfo* gDocShellLog; +static mozilla::LazyLogModule gDocShellLog("nsDocShell"); #endif -static PRLogModuleInfo* gDocShellLeakLog; +static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak");; const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties"; const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties"; @@ -818,17 +818,7 @@ nsDocShell::nsDocShell() CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup); } -#ifdef DEBUG - if (!gDocShellLog) { - gDocShellLog = PR_NewLogModule("nsDocShell"); - } -#endif - if (!gDocShellLeakLog) { - gDocShellLeakLog = PR_NewLogModule("nsDocShellLeak"); - } - if (gDocShellLeakLog) { - MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this)); - } + MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this)); #ifdef DEBUG // We're counting the number of |nsDocShells| to help find leaks diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 6400fe64dbd91..263231c1d709f 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -59,16 +59,9 @@ int32_t nsSHistory::sHistoryMaxTotalViewers = -1; // entries were touched, so that we can evict older entries first. static uint32_t gTouchCounter = 0; -static PRLogModuleInfo* -GetSHistoryLog() -{ - static PRLogModuleInfo* sLog; - if (!sLog) { - sLog = PR_NewLogModule("nsSHistory"); - } - return sLog; -} -#define LOG(format) MOZ_LOG(GetSHistoryLog(), mozilla::LogLevel::Debug, format) +static LazyLogModule gSHistoryLog("nsSHistory"); + +#define LOG(format) MOZ_LOG(gSHistoryLog, mozilla::LogLevel::Debug, format) // This macro makes it easier to print a log message which includes a URI's // spec. Example use: @@ -78,7 +71,7 @@ GetSHistoryLog() // #define LOG_SPEC(format, uri) \ PR_BEGIN_MACRO \ - if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) { \ + if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \ nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)"));\ if (uri) { \ uri->GetSpec(_specStr); \ @@ -96,7 +89,7 @@ GetSHistoryLog() // #define LOG_SHENTRY_SPEC(format, shentry) \ PR_BEGIN_MACRO \ - if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) { \ + if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \ nsCOMPtr uri; \ shentry->GetURI(getter_AddRefs(uri)); \ LOG_SPEC(format, uri); \ diff --git a/extensions/auth/nsAuth.h b/extensions/auth/nsAuth.h index 6abee650e2b92..a32072cdb7b97 100644 --- a/extensions/auth/nsAuth.h +++ b/extensions/auth/nsAuth.h @@ -20,7 +20,7 @@ enum pType { // set NSPR_LOG_MODULES=negotiateauth:4 // set NSPR_LOG_FILE=negotiateauth.log // -extern PRLogModuleInfo* gNegotiateLog; +extern mozilla::LazyLogModule gNegotiateLog; #define LOG(args) MOZ_LOG(gNegotiateLog, mozilla::LogLevel::Debug, args) diff --git a/extensions/auth/nsAuthFactory.cpp b/extensions/auth/nsAuthFactory.cpp index a6434251f4c40..d97d9ca859756 100644 --- a/extensions/auth/nsAuthFactory.cpp +++ b/extensions/auth/nsAuthFactory.cpp @@ -220,13 +220,12 @@ static const mozilla::Module::ContractIDEntry kAuthContracts[] = { }; //----------------------------------------------------------------------------- -PRLogModuleInfo *gNegotiateLog; +mozilla::LazyLogModule gNegotiateLog("negotiateauth"); // setup nspr logging ... static nsresult InitNegotiateAuth() { - gNegotiateLog = PR_NewLogModule("negotiateauth"); return NS_OK; } diff --git a/extensions/gio/nsGIOProtocolHandler.cpp b/extensions/gio/nsGIOProtocolHandler.cpp index 71db2d5da3ad3..00d842fba599a 100644 --- a/extensions/gio/nsGIOProtocolHandler.cpp +++ b/extensions/gio/nsGIOProtocolHandler.cpp @@ -37,7 +37,7 @@ //----------------------------------------------------------------------------- // NSPR_LOG_MODULES=gio:5 -static PRLogModuleInfo *sGIOLog; +static mozilla::LazyLogModule sGIOLog("gio"); #define LOG(args) MOZ_LOG(sGIOLog, mozilla::LogLevel::Debug, args) @@ -911,8 +911,6 @@ NS_IMPL_ISUPPORTS(nsGIOProtocolHandler, nsIProtocolHandler, nsIObserver) nsresult nsGIOProtocolHandler::Init() { - sGIOLog = PR_NewLogModule("gio"); - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); if (prefs) { diff --git a/extensions/pref/autoconfig/src/nsAutoConfig.cpp b/extensions/pref/autoconfig/src/nsAutoConfig.cpp index 56688e6390aac..c8c9b3098d305 100644 --- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp +++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp @@ -26,7 +26,7 @@ using mozilla::LogLevel; -PRLogModuleInfo *MCD; +mozilla::LazyLogModule MCD("MCD"); extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length, const char *filename, diff --git a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp index 4da1c1fa433f7..c5aafffc3b161 100644 --- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp +++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp @@ -19,7 +19,7 @@ #include "nsIScriptError.h" #include "jswrapper.h" -extern PRLogModuleInfo *MCD; +extern mozilla::LazyLogModule MCD; using mozilla::AutoSafeJSContext; //***************************************************************************** diff --git a/extensions/pref/autoconfig/src/nsReadConfig.cpp b/extensions/pref/autoconfig/src/nsReadConfig.cpp index 7ac886c7c9066..fe50f67cfb10b 100644 --- a/extensions/pref/autoconfig/src/nsReadConfig.cpp +++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp @@ -26,7 +26,7 @@ #include "nsXULAppAPI.h" #include "nsContentUtils.h" -extern PRLogModuleInfo *MCD; +extern mozilla::LazyLogModule MCD; extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length, const char *filename, @@ -75,8 +75,6 @@ NS_IMPL_ISUPPORTS(nsReadConfig, nsIReadConfig, nsIObserver) nsReadConfig::nsReadConfig() : mRead(false) { - if (!MCD) - MCD = PR_NewLogModule("MCD"); } nsresult nsReadConfig::Init() diff --git a/hal/Hal.cpp b/hal/Hal.cpp index 3117721b4692f..b982b0cfbbc02 100644 --- a/hal/Hal.cpp +++ b/hal/Hal.cpp @@ -61,13 +61,10 @@ using namespace mozilla::dom; namespace mozilla { namespace hal { -PRLogModuleInfo * +mozilla::LogModule * GetHalLog() { - static PRLogModuleInfo *sHalLog; - if (!sHalLog) { - sHalLog = PR_NewLogModule("hal"); - } + static mozilla::LazyLogModule sHalLog("hal"); return sHalLog; } diff --git a/hal/HalLog.h b/hal/HalLog.h index 7cdc9d88794b4..0d72e98d0fdd5 100644 --- a/hal/HalLog.h +++ b/hal/HalLog.h @@ -20,7 +20,7 @@ namespace mozilla { namespace hal { -extern PRLogModuleInfo *GetHalLog(); +mozilla::LogModule *GetHalLog(); #define HAL_LOG(...) \ MOZ_LOG(mozilla::hal::GetHalLog(), LogLevel::Debug, (__VA_ARGS__)) #define HAL_ERR(...) \ diff --git a/ipc/chromium/src/base/logging.cc b/ipc/chromium/src/base/logging.cc index 8b0f9d843c3f5..ed7facc96eb05 100644 --- a/ipc/chromium/src/base/logging.cc +++ b/ipc/chromium/src/base/logging.cc @@ -42,7 +42,7 @@ Logger::~Logger() break; } - MOZ_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "")); + MOZ_LOG(gChromiumPRLog, prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "")); if (xpcomlevel != -1) NS_DebugBreak(xpcomlevel, mMsg, NULL, mFile, mLine); @@ -58,15 +58,7 @@ Logger::printf(const char* fmt, ...) va_end(args); } -PRLogModuleInfo* Logger::gChromiumPRLog; - -PRLogModuleInfo* Logger::GetLog() -{ - if (!gChromiumPRLog) - gChromiumPRLog = PR_NewLogModule("chromium"); - return gChromiumPRLog; -} - +LazyLogModule Logger::gChromiumPRLog("chromium"); } // namespace mozilla mozilla::Logger& diff --git a/ipc/chromium/src/base/logging.h b/ipc/chromium/src/base/logging.h index 5a9c16655eed7..b8e3c64d9a018 100644 --- a/ipc/chromium/src/base/logging.h +++ b/ipc/chromium/src/base/logging.h @@ -45,8 +45,8 @@ class Logger void printf(const char* fmt, ...); private: - static PRLogModuleInfo* gChromiumPRLog; - static PRLogModuleInfo* GetLog(); + static mozilla::LazyLogModule gChromiumPRLog; +// static PRLogModuleInfo* GetLog(); LogSeverity mSeverity; const char* mFile; diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 1a095a922b189..0e5c2b32fb026 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -71,7 +71,7 @@ static const char kJSCachePrefix[] = "jsloader"; #define XPC_DESERIALIZATION_BUFFER_SIZE (12 * 8192) // NSPR_LOG_MODULES=JSComponentLoader:5 -static PRLogModuleInfo* gJSCLLog; +static LazyLogModule gJSCLLog("JSComponentLoader"); #define LOG(args) MOZ_LOG(gJSCLLog, mozilla::LogLevel::Debug, args) @@ -198,10 +198,6 @@ mozJSComponentLoader::mozJSComponentLoader() { MOZ_ASSERT(!sSelf, "mozJSComponentLoader should be a singleton"); - if (!gJSCLLog) { - gJSCLLog = PR_NewLogModule("JSComponentLoader"); - } - sSelf = this; } diff --git a/js/xpconnect/src/XPCLog.cpp b/js/xpconnect/src/XPCLog.cpp index 5624587c78856..515af2a478637 100644 --- a/js/xpconnect/src/XPCLog.cpp +++ b/js/xpconnect/src/XPCLog.cpp @@ -25,13 +25,12 @@ static char* g_Spaces; static int g_InitState = 0; static int g_Indent = 0; -static PRLogModuleInfo* g_LogMod = nullptr; +static mozilla::LazyLogModule g_LogMod("xpclog"); static bool Init() { - g_LogMod = PR_NewLogModule("xpclog"); g_Spaces = new char[SPACE_COUNT+1]; - if (!g_LogMod || !g_Spaces || !MOZ_LOG_TEST(g_LogMod,LogLevel::Error)) { + if (!g_Spaces || !MOZ_LOG_TEST(g_LogMod,LogLevel::Error)) { g_InitState = 1; XPC_Log_Finish(); return false; @@ -47,8 +46,6 @@ XPC_Log_Finish() { if (g_InitState == 1) { delete [] g_Spaces; - // we'd like to properly cleanup the LogModule, but nspr owns that - g_LogMod = nullptr; } g_InitState = -1; } diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index cf5c614b01c7d..b3ac37a6dadf7 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -202,7 +202,7 @@ xpc::ErrorReport::Init(JSErrorReport* aReport, const char* aFallbackMessage, mIsMuted = aReport->isMuted; } -static PRLogModuleInfo* gJSDiagnostics; +static LazyLogModule gJSDiagnostics("JSDiagnostics"); void xpc::ErrorReport::LogToConsole() @@ -232,15 +232,10 @@ xpc::ErrorReport::LogToConsoleWithStack(JS::HandleObject aStack) fflush(stderr); } - // Log to the PR Log Module. - if (!gJSDiagnostics) - gJSDiagnostics = PR_NewLogModule("JSDiagnostics"); - if (gJSDiagnostics) { - MOZ_LOG(gJSDiagnostics, - JSREPORT_IS_WARNING(mFlags) ? LogLevel::Warning : LogLevel::Error, - ("file %s, line %u\n%s", NS_LossyConvertUTF16toASCII(mFileName).get(), - mLineNumber, NS_LossyConvertUTF16toASCII(mErrorMsg).get())); - } + MOZ_LOG(gJSDiagnostics, + JSREPORT_IS_WARNING(mFlags) ? LogLevel::Warning : LogLevel::Error, + ("file %s, line %u\n%s", NS_LossyConvertUTF16toASCII(mFileName).get(), + mLineNumber, NS_LossyConvertUTF16toASCII(mErrorMsg).get())); // Log to the console. We do this last so that we can simply return if // there's no console service without affecting the other reporting diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index f49be0f64491f..e6fa63caa940d 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -48,7 +48,7 @@ static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID); // // set NSPR_LOG_MODULES=nsJarProtocol:5 // -static PRLogModuleInfo *gJarProtocolLog = nullptr; +static LazyLogModule gJarProtocolLog("nsJarProtocol"); #define LOG(args) MOZ_LOG(gJarProtocolLog, mozilla::LogLevel::Debug, args) #define LOG_ENABLED() MOZ_LOG_TEST(gJarProtocolLog, mozilla::LogLevel::Debug) @@ -203,9 +203,6 @@ nsJARChannel::nsJARChannel() , mOpeningRemote(false) , mBlockRemoteFiles(false) { - if (!gJarProtocolLog) - gJarProtocolLog = PR_NewLogModule("nsJarProtocol"); - mBlockRemoteFiles = Preferences::GetBool("network.jar.block-remote-files", false); // hold an owning reference to the jar handler diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp index ac66f6a191695..8903438b0e4f2 100644 --- a/parser/htmlparser/nsExpatDriver.cpp +++ b/parser/htmlparser/nsExpatDriver.cpp @@ -40,14 +40,7 @@ using mozilla::LogLevel; static const char16_t kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' }; -static PRLogModuleInfo * -GetExpatDriverLog() -{ - static PRLogModuleInfo *sLog; - if (!sLog) - sLog = PR_NewLogModule("expatdriver"); - return sLog; -} +static mozilla::LazyLogModule gExpatDriverLog("expatdriver"); /***************************** EXPAT CALL BACKS ******************************/ // The callback handlers that get called from the expat parser. @@ -1059,7 +1052,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens) nsScannerIterator end; aScanner.EndReading(end); - MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug, + MOZ_LOG(gExpatDriverLog, LogLevel::Debug, ("Remaining in expat's buffer: %i, remaining in scanner: %i.", mExpatBuffered, Distance(start, end))); @@ -1080,7 +1073,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens) length = 0; if (blocked) { - MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug, + MOZ_LOG(gExpatDriverLog, LogLevel::Debug, ("Resuming Expat, will parse data remaining in Expat's " "buffer.\nContent of Expat's buffer:\n-----\n%s\n-----\n", NS_ConvertUTF16toUTF8(currentExpatPosition.get(), @@ -1089,7 +1082,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens) else { NS_ASSERTION(mExpatBuffered == Distance(currentExpatPosition, end), "Didn't pass all the data to Expat?"); - MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug, + MOZ_LOG(gExpatDriverLog, LogLevel::Debug, ("Last call to Expat, will parse data remaining in Expat's " "buffer.\nContent of Expat's buffer:\n-----\n%s\n-----\n", NS_ConvertUTF16toUTF8(currentExpatPosition.get(), @@ -1100,7 +1093,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens) buffer = start.get(); length = uint32_t(start.size_forward()); - MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug, + MOZ_LOG(gExpatDriverLog, LogLevel::Debug, ("Calling Expat, will parse data remaining in Expat's buffer and " "new data.\nContent of Expat's buffer:\n-----\n%s\n-----\nNew " "data:\n-----\n%s\n-----\n", @@ -1140,7 +1133,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens) mExpatBuffered += length - consumed; if (BlockedOrInterrupted()) { - MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug, + MOZ_LOG(gExpatDriverLog, LogLevel::Debug, ("Blocked or interrupted parser (probably for loading linked " "stylesheets or scripts).")); @@ -1201,7 +1194,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens) aScanner.SetPosition(currentExpatPosition, true); aScanner.Mark(); - MOZ_LOG(GetExpatDriverLog(), LogLevel::Debug, + MOZ_LOG(gExpatDriverLog, LogLevel::Debug, ("Remaining in expat's buffer: %i, remaining in scanner: %i.", mExpatBuffered, Distance(currentExpatPosition, end))); diff --git a/rdf/base/nsCompositeDataSource.cpp b/rdf/base/nsCompositeDataSource.cpp index b42ae54603fb7..fdddd96732973 100644 --- a/rdf/base/nsCompositeDataSource.cpp +++ b/rdf/base/nsCompositeDataSource.cpp @@ -45,7 +45,7 @@ #include "mozilla/Logging.h" #include "prprf.h" #include -PRLogModuleInfo* nsRDFLog = nullptr; +mozilla::LazyLogModule nsRDFLog("RDF"); //---------------------------------------------------------------------- // @@ -490,8 +490,6 @@ CompositeDataSourceImpl::CompositeDataSourceImpl(void) mCoalesceDuplicateArcs(true), mUpdateBatchNest(0) { - if (nsRDFLog == nullptr) - nsRDFLog = PR_NewLogModule("RDF"); } //---------------------------------------------------------------------- diff --git a/rdf/base/nsInMemoryDataSource.cpp b/rdf/base/nsInMemoryDataSource.cpp index d61dbfb672dbf..30e5e17900fdd 100644 --- a/rdf/base/nsInMemoryDataSource.cpp +++ b/rdf/base/nsInMemoryDataSource.cpp @@ -352,10 +352,10 @@ class InMemoryDataSource : public nsIRDFDataSource, bool mPropagateChanges; private: - static PRLogModuleInfo* gLog; + static mozilla::LazyLogModule gLog; }; -PRLogModuleInfo* InMemoryDataSource::gLog; +mozilla::LazyLogModule InMemoryDataSource::gLog("InMemoryDataSource"); //---------------------------------------------------------------------- // @@ -743,9 +743,6 @@ InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter) mPropagateChanges = true; MOZ_COUNT_CTOR(InMemoryDataSource); - - if (! gLog) - gLog = PR_NewLogModule("InMemoryDataSource"); } diff --git a/rdf/base/nsRDFContentSink.cpp b/rdf/base/nsRDFContentSink.cpp index fe3f93e892dcb..2df96529ed69a 100644 --- a/rdf/base/nsRDFContentSink.cpp +++ b/rdf/base/nsRDFContentSink.cpp @@ -226,7 +226,7 @@ class RDFContentSinkImpl : public nsIRDFContentSink, nsCOMPtr mDocumentURL; private: - static PRLogModuleInfo* gLog; + static mozilla::LazyLogModule gLog; }; int32_t RDFContentSinkImpl::gRefCnt = 0; @@ -239,7 +239,7 @@ nsIRDFResource* RDFContentSinkImpl::kRDF_Bag; nsIRDFResource* RDFContentSinkImpl::kRDF_Seq; nsIRDFResource* RDFContentSinkImpl::kRDF_nextVal; -PRLogModuleInfo* RDFContentSinkImpl::gLog; +mozilla::LazyLogModule RDFContentSinkImpl::gLog("nsRDFContentSink"); //////////////////////////////////////////////////////////////////////// @@ -290,9 +290,6 @@ RDFContentSinkImpl::RDFContentSinkImpl() NS_RegisterStaticAtoms(rdf_atoms); } - - if (! gLog) - gLog = PR_NewLogModule("nsRDFContentSink"); } diff --git a/rdf/base/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index e977a41e8ff66..7774fbdbd2af9 100644 --- a/rdf/base/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -71,7 +71,7 @@ static NS_DEFINE_IID(kIRDFIntIID, NS_IRDFINT_IID); static NS_DEFINE_IID(kIRDFNodeIID, NS_IRDFNODE_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static PRLogModuleInfo* gLog = nullptr; +static LazyLogModule gLog("nsRDFService"); class BlobImpl; @@ -748,9 +748,6 @@ RDFServiceImpl::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get default resource factory"); if (NS_FAILED(rv)) return rv; - if (! gLog) - gLog = PR_NewLogModule("nsRDFService"); - return NS_OK; } diff --git a/rdf/base/nsRDFXMLDataSource.cpp b/rdf/base/nsRDFXMLDataSource.cpp index f7e8ecc024352..f99dbb3306bce 100644 --- a/rdf/base/nsRDFXMLDataSource.cpp +++ b/rdf/base/nsRDFXMLDataSource.cpp @@ -135,7 +135,7 @@ class RDFXMLDataSourceImpl : public nsIRDFDataSource, static int32_t gRefCnt; static nsIRDFService* gRDFService; - static PRLogModuleInfo* gLog; + static mozilla::LazyLogModule gLog; nsresult Init(); RDFXMLDataSourceImpl(void); @@ -359,7 +359,7 @@ class RDFXMLDataSourceImpl : public nsIRDFDataSource, int32_t RDFXMLDataSourceImpl::gRefCnt = 0; nsIRDFService* RDFXMLDataSourceImpl::gRDFService; -PRLogModuleInfo* RDFXMLDataSourceImpl::gLog; +mozilla::LazyLogModule RDFXMLDataSourceImpl::gLog("nsRDFXMLDataSource"); static const char kFileURIPrefix[] = "file:"; static const char kResourceURIPrefix[] = "resource:"; @@ -397,8 +397,6 @@ RDFXMLDataSourceImpl::RDFXMLDataSourceImpl(void) mIsDirty(false), mLoadState(eLoadState_Unloaded) { - if (! gLog) - gLog = PR_NewLogModule("nsRDFXMLDataSource"); } diff --git a/storage/VacuumManager.cpp b/storage/VacuumManager.cpp index bb0c5f509024c..5be2b17bd22e1 100644 --- a/storage/VacuumManager.cpp +++ b/storage/VacuumManager.cpp @@ -39,7 +39,7 @@ // Time between subsequent vacuum calls for a certain database. #define VACUUM_INTERVAL_SECONDS 30 * 86400 // 30 days. -extern PRLogModuleInfo *gStorageLog; +extern mozilla::LazyLogModule gStorageLog; namespace mozilla { namespace storage { diff --git a/storage/mozStorageAsyncStatement.cpp b/storage/mozStorageAsyncStatement.cpp index 7b4029b55caf4..7271080a53733 100644 --- a/storage/mozStorageAsyncStatement.cpp +++ b/storage/mozStorageAsyncStatement.cpp @@ -27,7 +27,7 @@ #include "mozilla/Logging.h" -extern PRLogModuleInfo *gStorageLog; +extern mozilla::LazyLogModule gStorageLog; namespace mozilla { namespace storage { diff --git a/storage/mozStorageConnection.cpp b/storage/mozStorageConnection.cpp index 5ac5b73f9f1ac..e581d5ad29363 100644 --- a/storage/mozStorageConnection.cpp +++ b/storage/mozStorageConnection.cpp @@ -49,7 +49,7 @@ // Maximum size of the pages cache per connection. #define MAX_CACHE_SIZE_KIBIBYTES 2048 // 2 MiB -PRLogModuleInfo* gStorageLog = nullptr; +mozilla::LazyLogModule gStorageLog("mozStorage"); // Checks that the protected code is running on the main-thread only if the // connection was also opened on it. @@ -692,9 +692,6 @@ Connection::initializeInternal() // Properly wrap the database handle's mutex. sharedDBMutex.initWithMutex(sqlite3_db_mutex(mDBConn)); - if (!gStorageLog) - gStorageLog = ::PR_NewLogModule("mozStorage"); - // SQLite tracing can slow down queries (especially long queries) // significantly. Don't trace unless the user is actively monitoring SQLite. if (MOZ_LOG_TEST(gStorageLog, LogLevel::Debug)) { diff --git a/storage/mozStoragePrivateHelpers.cpp b/storage/mozStoragePrivateHelpers.cpp index 61fe86bbcafe8..a89e1523be8e7 100644 --- a/storage/mozStoragePrivateHelpers.cpp +++ b/storage/mozStoragePrivateHelpers.cpp @@ -24,7 +24,7 @@ #include "mozIStorageBindingParams.h" #include "mozilla/Logging.h" -extern PRLogModuleInfo* gStorageLog; +extern mozilla::LazyLogModule gStorageLog; namespace mozilla { namespace storage { diff --git a/storage/mozStorageStatement.cpp b/storage/mozStorageStatement.cpp index 220e8fa15061b..b772f36f4590e 100644 --- a/storage/mozStorageStatement.cpp +++ b/storage/mozStorageStatement.cpp @@ -28,7 +28,7 @@ #include "mozilla/Logging.h" -extern PRLogModuleInfo* gStorageLog; +extern mozilla::LazyLogModule gStorageLog; namespace mozilla { namespace storage {