Title: [135790] trunk/Source/WTF
Revision
135790
Author
[email protected]
Date
2012-11-26 17:09:31 -0800 (Mon, 26 Nov 2012)

Log Message

DataLog to a file should work if there are multiple processes using WTF
https://bugs.webkit.org/show_bug.cgi?id=103323

Reviewed by Mark Hahnenberg.

Whereas before DataLog would open a file with the name you specified, now it'll open a file with the
name plus the PID appended to it. So if you are dealing with multiple processes running with DataLog
to a file enabled, you'll get multiple separate log files.

* wtf/DataLog.cpp:
(WTF::initializeLogFileOnce):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (135789 => 135790)


--- trunk/Source/WTF/ChangeLog	2012-11-27 00:56:30 UTC (rev 135789)
+++ trunk/Source/WTF/ChangeLog	2012-11-27 01:09:31 UTC (rev 135790)
@@ -1,3 +1,17 @@
+2012-11-26  Filip Pizlo  <[email protected]>
+
+        DataLog to a file should work if there are multiple processes using WTF
+        https://bugs.webkit.org/show_bug.cgi?id=103323
+
+        Reviewed by Mark Hahnenberg.
+
+        Whereas before DataLog would open a file with the name you specified, now it'll open a file with the
+        name plus the PID appended to it. So if you are dealing with multiple processes running with DataLog
+        to a file enabled, you'll get multiple separate log files.
+
+        * wtf/DataLog.cpp:
+        (WTF::initializeLogFileOnce):
+
 2012-11-26  Zeno Albisser  <[email protected]>
 
         [Qt] Fix the LLInt build on Mac

Modified: trunk/Source/WTF/wtf/DataLog.cpp (135789 => 135790)


--- trunk/Source/WTF/wtf/DataLog.cpp	2012-11-27 00:56:30 UTC (rev 135789)
+++ trunk/Source/WTF/wtf/DataLog.cpp	2012-11-27 01:09:31 UTC (rev 135790)
@@ -27,8 +27,13 @@
 #include "DataLog.h"
 #include <stdarg.h>
 #include <wtf/FilePrintStream.h>
+#include <wtf/WTFThreadData.h>
 #include <wtf/Threading.h>
 
+#if OS(UNIX)
+#include <unistd.h>
+#endif
+
 #if OS(WINCE)
 #ifndef _IONBF
 #define _IONBF 0x0004
@@ -37,8 +42,9 @@
 
 #define DATA_LOG_TO_FILE 0
 
-// Uncomment to force logging to the given file regardless of what the environment variable says.
-// #define DATA_LOG_FILENAME "/tmp/WTFLog.txt"
+// Uncomment to force logging to the given file regardless of what the environment variable says. Note that
+// we will append ".<pid>.txt" where <pid> is the PID.
+#define DATA_LOG_FILENAME "/tmp/WTFLog"
 
 namespace WTF {
 
@@ -56,12 +62,14 @@
 #else
     const char* filename = getenv("WTF_DATA_LOG_FILENAME");
 #endif
+    char actualFilename[1024];
+    snprintf(actualFilename, sizeof(actualFilename), "%s.%d.txt", filename, getpid());
     if (filename) {
-        FILE* rawFile = fopen(filename, "w");
+        FILE* rawFile = fopen(actualFilename, "w");
         if (rawFile)
             file = new FilePrintStream(rawFile);
         else
-            fprintf(stderr, "Warning: Could not open log file %s for writing.\n", filename);
+            fprintf(stderr, "Warning: Could not open log file %s for writing.\n", actualFilename);
     }
 #endif // DATA_LOG_TO_FILE
     if (!file)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to