Bug 1428979 - MOZ_LOG should include the pid with the thread name by default. r=erahm
authorAndrew Sutherland <asutherland@asutherland.org>
Tue, 09 Jan 2018 01:50:53 -0500
changeset 453009 e8663f41a424979b28d588bb850ffbb3fe4247cc
parent 453008 197ceff072eb520553745016696bfddb1513719a
child 453010 e61c4485494ec4823da22217f665d73858c57e35
child 453050 3a2979f591ff337bd769290c7f7fa139a1430c88
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1428979
milestone59.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 1428979 - MOZ_LOG should include the pid with the thread name by default. r=erahm
xpcom/base/Logging.cpp
--- a/xpcom/base/Logging.cpp
+++ b/xpcom/base/Logging.cpp
@@ -358,16 +358,18 @@ public:
     }
 
     return module;
   }
 
   void Print(const char* aName, LogLevel aLevel, const char* aFmt, va_list aArgs)
     MOZ_FORMAT_PRINTF(4, 0)
   {
+    // We don't do nuwa-style forking anymore, so our pid can't change.
+    static long pid = static_cast<long>(base::GetCurrentProcId());
     const size_t kBuffSize = 1024;
     char buff[kBuffSize];
 
     char* buffToWrite = buff;
     SmprintfPointer allocatedBuff;
 
     va_list argsCopy;
     va_copy(argsCopy, aArgs);
@@ -421,28 +423,28 @@ public:
     char noNameThread[40];
     if (!currentThreadName) {
       SprintfLiteral(noNameThread, "Unnamed thread %p", currentThread);
       currentThreadName = noNameThread;
     }
 
     if (!mAddTimestamp) {
       fprintf_stderr(out,
-                     "[%s]: %s/%s %s%s",
-                     currentThreadName, ToLogStr(aLevel),
+                     "[%ld:%s]: %s/%s %s%s",
+                     pid, currentThreadName, ToLogStr(aLevel),
                      aName, buffToWrite, newline);
     } else {
       PRExplodedTime now;
       PR_ExplodeTime(PR_Now(), PR_GMTParameters, &now);
       fprintf_stderr(
           out,
-          "%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - [%s]: %s/%s %s%s",
+          "%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - [%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,
-          currentThreadName, ToLogStr(aLevel),
+          pid, currentThreadName, ToLogStr(aLevel),
           aName, buffToWrite, newline);
     }
 
     if (mIsSync) {
       fflush(out);
     }
 
     if (mRotate > 0 && outFile) {