Skip to content

Commit

Permalink
Bug 1219482 - Replace PRLogModuleInfo with LazyLogModule in various f…
Browse files Browse the repository at this point in the history
…iles. r=bsmedberg
  • Loading branch information
astx30 committed Jan 28, 2016
1 parent 4461659 commit 5d88177
Show file tree
Hide file tree
Showing 27 changed files with 50 additions and 121 deletions.
16 changes: 3 additions & 13 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
17 changes: 5 additions & 12 deletions docshell/shistory/nsSHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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); \
Expand All @@ -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); \
Expand Down
2 changes: 1 addition & 1 deletion extensions/auth/nsAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions extensions/auth/nsAuthFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions extensions/gio/nsGIOProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion extensions/pref/autoconfig/src/nsAutoConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "nsIScriptError.h"
#include "jswrapper.h"

extern PRLogModuleInfo *MCD;
extern mozilla::LazyLogModule MCD;
using mozilla::AutoSafeJSContext;

//*****************************************************************************
Expand Down
4 changes: 1 addition & 3 deletions extensions/pref/autoconfig/src/nsReadConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -75,8 +75,6 @@ NS_IMPL_ISUPPORTS(nsReadConfig, nsIReadConfig, nsIObserver)
nsReadConfig::nsReadConfig() :
mRead(false)
{
if (!MCD)
MCD = PR_NewLogModule("MCD");
}

nsresult nsReadConfig::Init()
Expand Down
7 changes: 2 additions & 5 deletions hal/Hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion hal/HalLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(...) \
Expand Down
12 changes: 2 additions & 10 deletions ipc/chromium/src/base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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&
Expand Down
4 changes: 2 additions & 2 deletions ipc/chromium/src/base/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions js/xpconnect/loader/mozJSComponentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -198,10 +198,6 @@ mozJSComponentLoader::mozJSComponentLoader()
{
MOZ_ASSERT(!sSelf, "mozJSComponentLoader should be a singleton");

if (!gJSCLLog) {
gJSCLLog = PR_NewLogModule("JSComponentLoader");
}

sSelf = this;
}

Expand Down
7 changes: 2 additions & 5 deletions js/xpconnect/src/XPCLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
15 changes: 5 additions & 10 deletions js/xpconnect/src/nsXPConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions modules/libjar/nsJARChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
21 changes: 7 additions & 14 deletions parser/htmlparser/nsExpatDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)));

Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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",
Expand Down Expand Up @@ -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)."));

Expand Down Expand Up @@ -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)));

Expand Down
4 changes: 1 addition & 3 deletions rdf/base/nsCompositeDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "mozilla/Logging.h"
#include "prprf.h"
#include <stdio.h>
PRLogModuleInfo* nsRDFLog = nullptr;
mozilla::LazyLogModule nsRDFLog("RDF");

//----------------------------------------------------------------------
//
Expand Down Expand Up @@ -490,8 +490,6 @@ CompositeDataSourceImpl::CompositeDataSourceImpl(void)
mCoalesceDuplicateArcs(true),
mUpdateBatchNest(0)
{
if (nsRDFLog == nullptr)
nsRDFLog = PR_NewLogModule("RDF");
}

//----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 5d88177

Please sign in to comment.