Skip to content

Commit

Permalink
Bug 1165515 - Part 13-2: Replace usage of PRLogModuleLevel and PR_LOG…
Browse files Browse the repository at this point in the history
…_*. rs=froydnj

This is straightforward mapping of PR_LOG levels to their LogLevel
counterparts:
  PR_LOG_ERROR   -> LogLevel::Error
  PR_LOG_WARNING -> LogLevel::Warning
  PR_LOG_WARN    -> LogLevel::Warning
  PR_LOG_INFO    -> LogLevel::Info
  PR_LOG_DEBUG   -> LogLevel::Debug
  PR_LOG_NOTICE  -> LogLevel::Debug
  PR_LOG_VERBOSE -> LogLevel::Verbose

Instances of PRLogModuleLevel were mapped to a fully qualified
mozilla::LogLevel, instances of PR_LOG levels in #defines were mapped to a
fully qualified mozilla::LogLevel::* level, and all other instances were
mapped to us a shorter format of LogLevel::*.

Bustage for usage of the non-fully qualified LogLevel were fixed by adding
|using mozilla::LogLevel;| where appropriate.
  • Loading branch information
EricRahm committed Jun 2, 2015
1 parent 9bc7937 commit a9afd68
Show file tree
Hide file tree
Showing 368 changed files with 2,511 additions and 2,477 deletions.
30 changes: 15 additions & 15 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ nsDocShell::nsDocShell()
gDocShellLeakLog = PR_NewLogModule("nsDocShellLeak");
}
if (gDocShellLeakLog) {
MOZ_LOG(gDocShellLeakLog, PR_LOG_DEBUG, ("DOCSHELL %p created\n", this));
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this));
}

#ifdef DEBUG
Expand Down Expand Up @@ -958,7 +958,7 @@ nsDocShell::~nsDocShell()
}

if (gDocShellLeakLog) {
MOZ_LOG(gDocShellLeakLog, PR_LOG_DEBUG, ("DOCSHELL %p destroyed\n", this));
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p destroyed\n", this));
}

#ifdef DEBUG
Expand Down Expand Up @@ -1095,7 +1095,7 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
}

#if defined(DEBUG)
MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]: returning app cache container %p",
this, domDoc.get()));
#endif
Expand Down Expand Up @@ -1418,10 +1418,10 @@ nsDocShell::LoadURI(nsIURI* aURI,
}

#if defined(DEBUG)
if (MOZ_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
nsAutoCString uristr;
aURI->GetAsciiSpec(uristr);
MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]: loading %s with flags 0x%08x",
this, uristr.get(), aLoadFlags));
}
Expand Down Expand Up @@ -1540,7 +1540,7 @@ nsDocShell::LoadURI(nsIURI* aURI,

if (shEntry) {
#ifdef DEBUG
MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]: loading from session history", this));
#endif

Expand Down Expand Up @@ -1980,7 +1980,7 @@ bool
nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
bool aFireOnLocationChange, uint32_t aLocationFlags)
{
if (gDocShellLeakLog && MOZ_LOG_TEST(gDocShellLeakLog, PR_LOG_DEBUG)) {
if (gDocShellLeakLog && MOZ_LOG_TEST(gDocShellLeakLog, LogLevel::Debug)) {
nsAutoCString spec;
if (aURI) {
aURI->GetSpec(spec);
Expand Down Expand Up @@ -5302,7 +5302,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
nsIChannel* aFailedChannel)
{
#if defined(DEBUG)
if (MOZ_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
nsAutoCString spec;
aURI->GetSpec(spec);

Expand All @@ -5313,7 +5313,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
chanName.AssignLiteral("<no channel>");
}

MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]::LoadErrorPage(\"%s\", \"%s\", {...}, [%s])\n", this,
spec.get(), NS_ConvertUTF16toUTF8(aURL).get(), chanName.get()));
}
Expand Down Expand Up @@ -9606,7 +9606,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsresult rv = NS_OK;
mOriginalUriString.Truncate();

if (gDocShellLeakLog && MOZ_LOG_TEST(gDocShellLeakLog, PR_LOG_DEBUG)) {
if (gDocShellLeakLog && MOZ_LOG_TEST(gDocShellLeakLog, LogLevel::Debug)) {
nsAutoCString spec;
if (aURI) {
aURI->GetSpec(spec);
Expand Down Expand Up @@ -11165,7 +11165,7 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel, nsISupports* aOwner,
NS_PRECONDITION(!aChannel || !aOwner, "Shouldn't have both set");

#if defined(DEBUG)
if (MOZ_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
nsAutoCString spec;
aURI->GetSpec(spec);

Expand All @@ -11176,7 +11176,7 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel, nsISupports* aOwner,
chanName.AssignLiteral("<no channel>");
}

MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]::OnNewURI(\"%s\", [%s], 0x%x)\n", this, spec.get(),
chanName.get(), aLoadType));
}
Expand Down Expand Up @@ -11241,7 +11241,7 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel, nsISupports* aOwner,
// XXX This log message is almost useless because |updateSHistory|
// and |updateGHistory| are not correct at this point.

MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
(" shAvailable=%i updateSHistory=%i updateGHistory=%i"
" equalURI=%i\n",
shAvailable, updateSHistory, updateGHistory, equalUri));
Expand Down Expand Up @@ -11785,7 +11785,7 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
NS_PRECONDITION(!aChannel || !aOwner, "Shouldn't have both set");

#if defined(DEBUG)
if (MOZ_LOG_TEST(gDocShellLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
nsAutoCString spec;
aURI->GetSpec(spec);

Expand All @@ -11796,7 +11796,7 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
chanName.AssignLiteral("<no channel>");
}

MOZ_LOG(gDocShellLog, PR_LOG_DEBUG,
MOZ_LOG(gDocShellLog, LogLevel::Debug,
("nsDocShell[%p]::AddToSessionHistory(\"%s\", [%s])\n",
this, spec.get(), chanName.get()));
}
Expand Down
6 changes: 3 additions & 3 deletions docshell/shistory/nsSHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ GetSHistoryLog()
}
return sLog;
}
#define LOG(format) MOZ_LOG(GetSHistoryLog(), PR_LOG_DEBUG, format)
#define LOG(format) MOZ_LOG(GetSHistoryLog(), 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 +78,7 @@ GetSHistoryLog()
//
#define LOG_SPEC(format, uri) \
PR_BEGIN_MACRO \
if (MOZ_LOG_TEST(GetSHistoryLog(), PR_LOG_DEBUG)) { \
if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) { \
nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)"));\
if (uri) { \
uri->GetSpec(_specStr); \
Expand All @@ -96,7 +96,7 @@ GetSHistoryLog()
//
#define LOG_SHENTRY_SPEC(format, shentry) \
PR_BEGIN_MACRO \
if (MOZ_LOG_TEST(GetSHistoryLog(), PR_LOG_DEBUG)) { \
if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) { \
nsCOMPtr<nsIURI> uri; \
shentry->GetURI(getter_AddRefs(uri)); \
LOG_SPEC(format, uri); \
Expand Down
2 changes: 1 addition & 1 deletion dom/base/ThirdPartyUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
//
static PRLogModuleInfo *gThirdPartyLog;
#undef LOG
#define LOG(args) MOZ_LOG(gThirdPartyLog, PR_LOG_DEBUG, args)
#define LOG(args) MOZ_LOG(gThirdPartyLog, mozilla::LogLevel::Debug, args)

nsresult
ThirdPartyUtil::Init()
Expand Down
4 changes: 2 additions & 2 deletions dom/base/nsContentPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
#define LOG_CHECK(logType) \
PR_BEGIN_MACRO \
/* skip all this nonsense if the call failed or logging is disabled */ \
if (NS_SUCCEEDED(rv) && MOZ_LOG_TEST(gConPolLog, PR_LOG_DEBUG)) { \
if (NS_SUCCEEDED(rv) && MOZ_LOG_TEST(gConPolLog, LogLevel::Debug)) { \
const char *resultName; \
if (decision) { \
resultName = NS_CP_ResponseName(*decision); \
Expand All @@ -203,7 +203,7 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
if (requestingLocation) { \
requestingLocation->GetSpec(refSpec); \
} \
MOZ_LOG(gConPolLog, PR_LOG_DEBUG, \
MOZ_LOG(gConPolLog, LogLevel::Debug, \
("Content Policy: " logType ": <%s> <Ref:%s> result=%s", \
spec.get(), refSpec.get(), resultName) \
); \
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsDOMDataChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

extern PRLogModuleInfo* GetDataChannelLog();
#undef LOG
#define LOG(args) MOZ_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args)
#define LOG(args) MOZ_LOG(GetDataChannelLog(), mozilla::LogLevel::Debug, args)


#include "nsDOMDataChannelDeclarations.h"
Expand Down
26 changes: 13 additions & 13 deletions dom/base/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ nsDocument::nsDocument(const char* aContentType)
gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak");

if (gDocumentLeakPRLog)
MOZ_LOG(gDocumentLeakPRLog, PR_LOG_DEBUG,
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p created", this));

if (!gCspPRLog)
Expand Down Expand Up @@ -1639,7 +1639,7 @@ nsIDocument::~nsIDocument()
nsDocument::~nsDocument()
{
if (gDocumentLeakPRLog)
MOZ_LOG(gDocumentLeakPRLog, PR_LOG_DEBUG,
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p destroyed", this));

NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document");
Expand Down Expand Up @@ -2305,7 +2305,7 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
{
NS_PRECONDITION(aURI, "Null URI passed to ResetToURI");

if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, PR_LOG_DEBUG)) {
if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) {
nsAutoCString spec;
aURI->GetSpec(spec);
PR_LogPrint("DOCUMENT %p ResetToURI %s", this, spec.get());
Expand Down Expand Up @@ -2638,7 +2638,7 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsIStreamListener **aDocListener,
bool aReset, nsIContentSink* aSink)
{
if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, PR_LOG_DEBUG)) {
if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) {
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
nsAutoCString spec;
Expand Down Expand Up @@ -2773,7 +2773,7 @@ AppendCSPFromHeader(nsIContentSecurityPolicy* csp,
rv = csp->AppendPolicy(policy, aReportOnly);
NS_ENSURE_SUCCESS(rv, rv);
{
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG,
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSP refined with policy: \"%s\"",
NS_ConvertUTF16toUTF8(policy).get()));
}
Expand Down Expand Up @@ -2813,7 +2813,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)
{
nsCOMPtr<nsIContentSecurityPolicy> csp;
if (!CSPService::sCSPEnabled) {
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG,
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSP is disabled, skipping CSP init for document %p", this));
return NS_OK;
}
Expand Down Expand Up @@ -2866,12 +2866,12 @@ nsDocument::InitCSP(nsIChannel* aChannel)
!applyLoopCSP &&
cspHeaderValue.IsEmpty() &&
cspROHeaderValue.IsEmpty()) {
if (MOZ_LOG_TEST(gCspPRLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gCspPRLog, LogLevel::Debug)) {
nsCOMPtr<nsIURI> chanURI;
aChannel->GetURI(getter_AddRefs(chanURI));
nsAutoCString aspec;
chanURI->GetAsciiSpec(aspec);
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG,
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("no CSP for document, %s, %s",
aspec.get(),
applyAppDefaultCSP ? "is app" : "not an app"));
Expand All @@ -2880,7 +2880,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)
return NS_OK;
}

MOZ_LOG(gCspPRLog, PR_LOG_DEBUG, ("Document is an app or CSP header specified %p", this));
MOZ_LOG(gCspPRLog, LogLevel::Debug, ("Document is an app or CSP header specified %p", this));

nsresult rv;

Expand All @@ -2899,7 +2899,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)
NS_ENSURE_SUCCESS(rv, rv);

if (csp) {
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG, ("%s %s %s",
MOZ_LOG(gCspPRLog, LogLevel::Debug, ("%s %s %s",
"This document is sharing principal with another document.",
"Since the document is an app, CSP was already set.",
"Skipping attempt to set CSP."));
Expand All @@ -2910,7 +2910,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)
csp = do_CreateInstance("@mozilla.org/cspcontext;1", &rv);

if (NS_FAILED(rv)) {
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG, ("Failed to create CSP object: %x", rv));
MOZ_LOG(gCspPRLog, LogLevel::Debug, ("Failed to create CSP object: %x", rv));
return rv;
}

Expand Down Expand Up @@ -2963,7 +2963,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)
rv = csp->PermitsAncestry(docShell, &safeAncestry);

if (NS_FAILED(rv) || !safeAncestry) {
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG,
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSP doesn't like frame's ancestry, not loading."));
// stop! ERROR page!
aChannel->Cancel(NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION);
Expand All @@ -2988,7 +2988,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)

rv = principal->SetCsp(csp);
NS_ENSURE_SUCCESS(rv, rv);
MOZ_LOG(gCspPRLog, PR_LOG_DEBUG,
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("Inserted CSP into principal %p", principal));

return NS_OK;
Expand Down
20 changes: 10 additions & 10 deletions dom/base/nsFocusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ using namespace mozilla::widget;
PRLogModuleInfo* gFocusLog;
PRLogModuleInfo* gFocusNavigationLog;

#define LOGFOCUS(args) MOZ_LOG(gFocusLog, PR_LOG_DEBUG, args)
#define LOGFOCUSNAVIGATION(args) MOZ_LOG(gFocusNavigationLog, PR_LOG_DEBUG, args)
#define LOGFOCUS(args) MOZ_LOG(gFocusLog, mozilla::LogLevel::Debug, args)
#define LOGFOCUSNAVIGATION(args) MOZ_LOG(gFocusNavigationLog, mozilla::LogLevel::Debug, args)

#define LOGTAG(log, format, content) \
if (MOZ_LOG_TEST(log, PR_LOG_DEBUG)) { \
if (MOZ_LOG_TEST(log, LogLevel::Debug)) { \
nsAutoCString tag(NS_LITERAL_CSTRING("(none)")); \
if (content) { \
content->NodeInfo()->NameAtom()->ToUTF8String(tag); \
} \
MOZ_LOG(log, PR_LOG_DEBUG, (format, tag.get())); \
MOZ_LOG(log, LogLevel::Debug, (format, tag.get())); \
}

#define LOGCONTENT(format, content) LOGTAG(gFocusLog, format, content)
Expand Down Expand Up @@ -482,7 +482,7 @@ nsFocusManager::MoveFocus(nsIDOMWindow* aWindow, nsIDOMElement* aStartElement,

LOGFOCUS(("<<MoveFocus begin Type: %d Flags: %x>>", aType, aFlags));

if (MOZ_LOG_TEST(gFocusLog, PR_LOG_DEBUG) && mFocusedWindow) {
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug) && mFocusedWindow) {
nsIDocument* doc = mFocusedWindow->GetExtantDoc();
if (doc && doc->GetDocumentURI()) {
nsAutoCString spec;
Expand Down Expand Up @@ -638,7 +638,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow)
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
NS_ENSURE_TRUE(window && window->IsOuterWindow(), NS_ERROR_INVALID_ARG);

if (MOZ_LOG_TEST(gFocusLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
LOGFOCUS(("Window %p Raised [Currently: %p %p]", aWindow, mActiveWindow.get(), mFocusedWindow.get()));
nsAutoCString spec;
nsIDocument* doc = window->GetExtantDoc();
Expand Down Expand Up @@ -734,7 +734,7 @@ nsFocusManager::WindowLowered(nsIDOMWindow* aWindow)
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
NS_ENSURE_TRUE(window && window->IsOuterWindow(), NS_ERROR_INVALID_ARG);

if (MOZ_LOG_TEST(gFocusLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
LOGFOCUS(("Window %p Lowered [Currently: %p %p]", aWindow, mActiveWindow.get(), mFocusedWindow.get()));
nsAutoCString spec;
nsIDocument* doc = window->GetExtantDoc();
Expand Down Expand Up @@ -852,7 +852,7 @@ nsFocusManager::WindowShown(nsIDOMWindow* aWindow, bool aNeedsFocus)

window = window->GetOuterWindow();

if (MOZ_LOG_TEST(gFocusLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
LOGFOCUS(("Window %p Shown [Currently: %p %p]", window.get(), mActiveWindow.get(), mFocusedWindow.get()));
nsAutoCString spec;
nsIDocument* doc = window->GetExtantDoc();
Expand Down Expand Up @@ -907,7 +907,7 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow)

window = window->GetOuterWindow();

if (MOZ_LOG_TEST(gFocusLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
LOGFOCUS(("Window %p Hidden [Currently: %p %p]", window.get(), mActiveWindow.get(), mFocusedWindow.get()));
nsAutoCString spec;
nsIDocument* doc = window->GetExtantDoc();
Expand Down Expand Up @@ -1777,7 +1777,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,

LOGCONTENT("Element %s has been focused", aContent);

if (MOZ_LOG_TEST(gFocusLog, PR_LOG_DEBUG)) {
if (MOZ_LOG_TEST(gFocusLog, LogLevel::Debug)) {
nsIDocument* docm = aWindow->GetExtantDoc();
if (docm) {
LOGCONTENT(" from %s", docm->GetRootElement());
Expand Down
Loading

0 comments on commit a9afd68

Please sign in to comment.