Skip to content

Commit

Permalink
Bug 1165515 - Part 14: Undef PR_LOG macros when using mozilla/Logging…
Browse files Browse the repository at this point in the history
….h. r=froydnj

Make it harder for users to accidentally reintroduce usage of the PR_LOG macros
when using 'mozilla/Logging.h'. This can still be worked around by directly
including 'prlog.h' (and not 'mozilla/Logging.h') if absolutely necessary.
  • Loading branch information
EricRahm committed Jun 3, 2015
1 parent b09bb49 commit 4c4b535
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
14 changes: 7 additions & 7 deletions ipc/chromium/src/base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ namespace mozilla {

Logger::~Logger()
{
PRLogModuleLevel prlevel = PR_LOG_DEBUG;
LogLevel prlevel = LogLevel::Debug;
int xpcomlevel = -1;

switch (mSeverity) {
case LOG_INFO:
prlevel = PR_LOG_DEBUG;
prlevel = LogLevel::Debug;
xpcomlevel = -1;
break;

case LOG_WARNING:
prlevel = PR_LOG_WARNING;
prlevel = LogLevel::Warning;
xpcomlevel = NS_DEBUG_WARNING;
break;

case LOG_ERROR:
prlevel = PR_LOG_ERROR;
prlevel = LogLevel::Error;
xpcomlevel = NS_DEBUG_WARNING;
break;

case LOG_ERROR_REPORT:
prlevel = PR_LOG_ERROR;
prlevel = LogLevel::Error;
xpcomlevel = NS_DEBUG_ASSERTION;
break;

case LOG_FATAL:
prlevel = PR_LOG_ERROR;
prlevel = LogLevel::Error;
xpcomlevel = NS_DEBUG_ABORT;
break;
}

PR_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
MOZ_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "<no message>"));
if (xpcomlevel != -1)
NS_DebugBreak(xpcomlevel, mMsg, NULL, mFile, mLine);

Expand Down
4 changes: 0 additions & 4 deletions netwerk/cache2/CacheEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ CacheEntry::~CacheEntry()
MOZ_COUNT_DTOR(CacheEntry);
}

#ifdef PR_LOG

char const * CacheEntry::StateString(uint32_t aState)
{
switch (aState) {
Expand All @@ -215,8 +213,6 @@ char const * CacheEntry::StateString(uint32_t aState)
return "?";
}

#endif

nsresult CacheEntry::HashingKeyWithStorage(nsACString &aResult) const
{
return HashingKey(mStorageID, mEnhanceID, mURI, aResult);
Expand Down
2 changes: 0 additions & 2 deletions netwerk/cache2/CacheEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,7 @@ class CacheEntry final : public nsICacheEntry
// fails to open an output stream.
bool mHasData : 1;

#ifdef PR_LOG
static char const * StateString(uint32_t aState);
#endif

enum EState { // transiting to:
NOTLOADED = 0, // -> LOADING | EMPTY
Expand Down
3 changes: 3 additions & 0 deletions xpcom/glue/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ inline bool log_test(const PRLogModuleInfo* module, LogLevel level) {
} \
PR_END_MACRO

#undef PR_LOG
#undef PR_LOG_TEST

#endif // mozilla_logging_h

0 comments on commit 4c4b535

Please sign in to comment.