Bug 1470508 Output the process name in MOZ_LOG r=froydnj
authorTom Ritter <tom@mozilla.com>
Fri, 22 Jun 2018 12:31:35 -0500
changeset 423650 d0bc7c47b115c63083165c796e83a6419b2c5520
parent 423649 638eb8a41245f6d9932861afda21edd5e0b2618a
child 423651 c26fe9f3466f991302078b3045ac922df40890a2
push id34190
push userebalazs@mozilla.com
push dateTue, 26 Jun 2018 14:53:39 +0000
treeherdermozilla-central@348090c6b5c4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1470508
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1470508 Output the process name in MOZ_LOG r=froydnj
xpcom/base/Logging.cpp
xpcom/base/nsDebugImpl.cpp
xpcom/base/nsDebugImpl.h
--- a/xpcom/base/Logging.cpp
+++ b/xpcom/base/Logging.cpp
@@ -14,16 +14,17 @@
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Printf.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "MainThreadUtils.h"
 #include "nsClassHashtable.h"
 #include "nsDebug.h"
+#include "nsDebugImpl.h"
 #include "NSPRLogModulesParser.h"
 #include "LogCommandLineHandler.h"
 
 #include "prenv.h"
 #ifdef XP_WIN
 #include <process.h>
 #else
 #include <sys/types.h>
@@ -458,31 +459,31 @@ public:
     if (!currentThreadName) {
       SprintfLiteral(noNameThread, "Unnamed thread %p", currentThread);
       currentThreadName = noNameThread;
     }
 
     if (!mAddTimestamp) {
       if (!mIsRaw) {
         fprintf_stderr(out,
-                      "[%ld:%s]: %s/%s %s%s",
-                      pid, currentThreadName, ToLogStr(aLevel),
+                      "[%s %ld: %s]: %s/%s %s%s",
+                      nsDebugImpl::GetMultiprocessMode(), pid, currentThreadName, ToLogStr(aLevel),
                       aName, buffToWrite, newline);
       } else {
         fprintf_stderr(out, "%s%s", buffToWrite, newline);
       }
     } else {
       PRExplodedTime now;
       PR_ExplodeTime(PR_Now(), PR_GMTParameters, &now);
       fprintf_stderr(
           out,
-          "%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - [%ld:%s]: %s/%s %s%s",
+          "%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - [%s %ld: %s]: %s/%s %s%s",
           now.tm_year, now.tm_month + 1, now.tm_mday,
           now.tm_hour, now.tm_min, now.tm_sec, now.tm_usec,
-          pid, currentThreadName, ToLogStr(aLevel),
+          nsDebugImpl::GetMultiprocessMode(), pid, currentThreadName, ToLogStr(aLevel),
           aName, buffToWrite, newline);
     }
 
     if (mIsSync) {
       fflush(out);
     }
 
     if (mRotate > 0 && outFile) {
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -216,16 +216,22 @@ nsDebugImpl::GetIsDebuggerAttached(bool*
 }
 
 /* static */ void
 nsDebugImpl::SetMultiprocessMode(const char* aDesc)
 {
   sMultiprocessDescription = aDesc;
 }
 
+/* static */ const char *
+nsDebugImpl::GetMultiprocessMode()
+{
+  return sMultiprocessDescription;
+}
+
 /**
  * Implementation of the nsDebug methods. Note that this code is
  * always compiled in, in case some other module that uses it is
  * compiled with debugging even if this library is not.
  */
 enum nsAssertBehavior
 {
   NS_ASSERT_UNINITIALIZED,
--- a/xpcom/base/nsDebugImpl.h
+++ b/xpcom/base/nsDebugImpl.h
@@ -15,16 +15,21 @@ public:
   nsDebugImpl() = default;
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDEBUG2
 
   static nsresult Create(nsISupports* aOuter, const nsIID& aIID,
                          void** aInstancePtr);
 
   /*
+   * If we are in multiprocess mode, return the process name.
+   */
+  static const char* GetMultiprocessMode();
+
+  /*
    * Inform nsDebugImpl that we're in multiprocess mode.
    *
    * If aDesc is not nullptr, the string it points to must be
    * statically-allocated (i.e., it must be a string literal).
    */
   static void SetMultiprocessMode(const char* aDesc);
 };