Bug 1165515 - Part 14: Undef PR_LOG macros when using mozilla/Logging.h. r=froydnj
☠☠ backed out by 3f1f9238e02f ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Mon, 01 Jun 2015 14:31:01 -0700
changeset 266747 9b97e2aa2ed94fea7cda84b8b821b65e745ecc83
parent 266746 150606c022a29517f43ee6907075170db825c947
child 266748 ac4a2f9535249c2ed2b54d83c1d2d610e7b2e993
push idunknown
push userunknown
push dateunknown
reviewersfroydnj
bugs1165515
milestone41.0a1
Bug 1165515 - Part 14: Undef PR_LOG macros when using mozilla/Logging.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.
ipc/chromium/src/base/logging.cc
netwerk/cache2/CacheEntry.cpp
netwerk/cache2/CacheEntry.h
xpcom/glue/Logging.h
--- a/ipc/chromium/src/base/logging.cc
+++ b/ipc/chromium/src/base/logging.cc
@@ -7,47 +7,47 @@
 #include "prprf.h"
 #include "base/string_util.h"
 #include "nsXPCOM.h"
 
 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);
 
   PR_Free(mMsg);
 }
 
 void
 Logger::printf(const char* fmt, ...)
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -194,34 +194,30 @@ CacheEntry::CacheEntry(const nsACString&
 CacheEntry::~CacheEntry()
 {
   ProxyRelease(mURI, mReleaseThread);
 
   LOG(("CacheEntry::~CacheEntry [this=%p]", this));
   MOZ_COUNT_DTOR(CacheEntry);
 }
 
-#ifdef PR_LOG
-
 char const * CacheEntry::StateString(uint32_t aState)
 {
   switch (aState) {
   case NOTLOADED:     return "NOTLOADED";
   case LOADING:       return "LOADING";
   case EMPTY:         return "EMPTY";
   case WRITING:       return "WRITING";
   case READY:         return "READY";
   case REVALIDATING:  return "REVALIDATING";
   }
 
   return "?";
 }
 
-#endif
-
 nsresult CacheEntry::HashingKeyWithStorage(nsACString &aResult) const
 {
   return HashingKey(mStorageID, mEnhanceID, mURI, aResult);
 }
 
 nsresult CacheEntry::HashingKey(nsACString &aResult) const
 {
   return HashingKey(EmptyCString(), mEnhanceID, mURI, aResult);
--- a/netwerk/cache2/CacheEntry.h
+++ b/netwerk/cache2/CacheEntry.h
@@ -289,19 +289,17 @@ private:
   // true: after load and an existing file, or after output stream has been opened.
   //       note - when opening an input stream, and this flag is false, output stream
   //       is open along ; this makes input streams on new entries behave correctly
   //       when EOF is reached (WOULD_BLOCK is returned).
   // false: after load and a new file, or dropped to back to false when a writer
   //        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
     LOADING = 1,     // -> EMPTY | READY
     EMPTY = 2,       // -> WRITING
     WRITING = 3,     // -> EMPTY | READY
     READY = 4,       // -> REVALIDATING
     REVALIDATING = 5 // -> READY
--- a/xpcom/glue/Logging.h
+++ b/xpcom/glue/Logging.h
@@ -58,10 +58,13 @@ inline bool log_test(const PRLogModuleIn
 
 #define MOZ_LOG(_module,_level,_args)     \
   PR_BEGIN_MACRO             \
     if (MOZ_LOG_TEST(_module,_level)) { \
       PR_LogPrint _args;         \
     }                     \
   PR_END_MACRO
 
+#undef PR_LOG
+#undef PR_LOG_TEST
+
 #endif // mozilla_logging_h