Bug 1219482 - Replace PRLogModuleInfo with LazyLogModule in various files. r=bsmedberg

--HG--
extra : rebase_source : 37e8f53a8aa5242058ab8fc867804cbc8940653e
This commit is contained in:
sajitk 2016-01-28 10:35:00 -05:00
parent 571b20fd9f
commit 6fdb9b782e
27 changed files with 50 additions and 121 deletions

View File

@ -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

View File

@ -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<nsIURI> uri; \
shentry->GetURI(getter_AddRefs(uri)); \
LOG_SPEC(format, uri); \

View File

@ -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)

View File

@ -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;
}

View File

@ -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<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs)
{

View File

@ -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,

View File

@ -19,7 +19,7 @@
#include "nsIScriptError.h"
#include "jswrapper.h"
extern PRLogModuleInfo *MCD;
extern mozilla::LazyLogModule MCD;
using mozilla::AutoSafeJSContext;
//*****************************************************************************

View File

@ -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()

View File

@ -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;
}

View File

@ -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(...) \

View File

@ -42,7 +42,7 @@ Logger::~Logger()
break;
}
MOZ_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
MOZ_LOG(gChromiumPRLog, prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
if (xpcomlevel != -1)
NS_DebugBreak(xpcomlevel, mMsg, NULL, mFile, mLine);
@ -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&

View File

@ -45,8 +45,8 @@ public:
void printf(const char* fmt, ...);
private:
static PRLogModuleInfo* gChromiumPRLog;
static PRLogModuleInfo* GetLog();
static mozilla::LazyLogModule gChromiumPRLog;
// static PRLogModuleInfo* GetLog();
LogSeverity mSeverity;
const char* mFile;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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)));

View File

@ -45,7 +45,7 @@
#include "mozilla/Logging.h"
#include "prprf.h"
#include <stdio.h>
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");
}
//----------------------------------------------------------------------

View File

@ -352,10 +352,10 @@ public:
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");
}

View File

@ -226,7 +226,7 @@ protected:
nsCOMPtr<nsIURI> 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");
}

View File

@ -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;
}

View File

@ -135,7 +135,7 @@ protected:
static int32_t gRefCnt;
static nsIRDFService* gRDFService;
static PRLogModuleInfo* gLog;
static mozilla::LazyLogModule gLog;
nsresult Init();
RDFXMLDataSourceImpl(void);
@ -359,7 +359,7 @@ protected:
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");
}

View File

@ -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 {

View File

@ -27,7 +27,7 @@
#include "mozilla/Logging.h"
extern PRLogModuleInfo *gStorageLog;
extern mozilla::LazyLogModule gStorageLog;
namespace mozilla {
namespace storage {

View File

@ -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)) {

View File

@ -24,7 +24,7 @@
#include "mozIStorageBindingParams.h"
#include "mozilla/Logging.h"
extern PRLogModuleInfo* gStorageLog;
extern mozilla::LazyLogModule gStorageLog;
namespace mozilla {
namespace storage {

View File

@ -28,7 +28,7 @@
#include "mozilla/Logging.h"
extern PRLogModuleInfo* gStorageLog;
extern mozilla::LazyLogModule gStorageLog;
namespace mozilla {
namespace storage {