<rdar://problem/10583749> WebKit2 should log to both ASL and stderr
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 01:24:07 +0000 (01:24 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 01:24:07 +0000 (01:24 +0000)
Source/WebKit2:

Replace direct calls to fprintf stderr with calls to WTFLogAlways.

Reviewed by Sam Weinig.

* PluginProcess/mac/PluginProcessMainMac.mm:
(WebKit::PluginProcessMain):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::checkURLReceivedFromWebProcess):
(WebKit::WebProcessProxy::didReceiveInvalidMessage):
* WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp:
(WebKit::InjectedBundle::load):
* WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm:
(readSandboxProfile):
(WKN_EnterSandbox):
* WebProcess/mac/WebProcessMac.mm:
(WebKit::initializeSandbox):
* WebProcess/mac/WebProcessMainMac.mm:
(WebKit::WebProcessMain):

Source/WTF:

Reviewed by Sam Weinig.

* wtf/Assertions.cpp: Add a WTFLogAlways function that unconditionally logs the given message.
* wtf/Assertions.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113800 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/Assertions.cpp
Source/WTF/wtf/Assertions.h
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm
Source/WebKit2/WebProcess/mac/WebProcessMac.mm
Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm

index a35a855..2a14578 100644 (file)
@@ -1,3 +1,12 @@
+2012-04-10  Mark Rowe  <mrowe@apple.com>
+
+        <rdar://problem/10583749> WebKit2 should log to both ASL and stderr
+
+        Reviewed by Sam Weinig.
+
+        * wtf/Assertions.cpp: Add a WTFLogAlways function that unconditionally logs the given message.
+        * wtf/Assertions.h:
+
 2012-04-10  Patrick Gansterer  <paroga@webkit.org>
 
         Cleanup wtf/Platform.h and config.h files
index 89ade35..db2c146 100644 (file)
@@ -409,4 +409,16 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann
     printCallSite(file, line, function);
 }
 
+void WTFLogAlways(const char* format, ...)
+{
+#if PLATFORM(BLACKBERRY)
+    WTFLogLocker locker(BlackBerry::Platform::LogLevelInfo);
+#endif
+
+    va_list args;
+    va_start(args, format);
+    vprintf_stderr_with_trailing_newline(format, args);
+    va_end(args);
+}
+
 } // extern "C"
index 7c38f56..b78951e 100644 (file)
@@ -143,6 +143,7 @@ WTF_EXPORT_PRIVATE void WTFReportFatalError(const char* file, int line, const ch
 WTF_EXPORT_PRIVATE void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
 WTF_EXPORT_PRIVATE void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
 WTF_EXPORT_PRIVATE void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
+WTF_EXPORT_PRIVATE void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
 
 WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
 WTF_EXPORT_PRIVATE void WTFReportBacktrace();
index f80c6eb..af86574 100644 (file)
@@ -1,3 +1,26 @@
+2012-04-10  Mark Rowe  <mrowe@apple.com>
+
+        <rdar://problem/10583749> WebKit2 should log to both ASL and stderr
+
+        Replace direct calls to fprintf stderr with calls to WTFLogAlways.
+
+        Reviewed by Sam Weinig.
+
+        * PluginProcess/mac/PluginProcessMainMac.mm:
+        (WebKit::PluginProcessMain):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::checkURLReceivedFromWebProcess):
+        (WebKit::WebProcessProxy::didReceiveInvalidMessage):
+        * WebProcess/InjectedBundle/mac/InjectedBundleMac.cpp:
+        (WebKit::InjectedBundle::load):
+        * WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm:
+        (readSandboxProfile):
+        (WKN_EnterSandbox):
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::initializeSandbox):
+        * WebProcess/mac/WebProcessMainMac.mm:
+        (WebKit::WebProcessMain):
+
 2012-04-10  Yael Aharon  <yael.aharon@nokia.com>
 
         Unreviewed build fix after r113791.
index 6f33004..e6b394c 100644 (file)
@@ -79,7 +79,7 @@ int PluginProcessMain(const CommandLine& commandLine)
     mach_port_t serverPort;
     kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort);
     if (kr) {
-        fprintf(stderr, "bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
+        WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
         return EXIT_FAILURE;
     }
 
index e8dfd81..7ee5328 100644 (file)
@@ -255,7 +255,7 @@ bool WebProcessProxy::checkURLReceivedFromWebProcess(const KURL& url)
     }
 
     // A Web process that was never asked to load a file URL should not ever ask us to do anything with a file URL.
-    fprintf(stderr, "Received an unexpected URL from the web process: '%s'\n", url.string().utf8().data());
+    WTFLogAlways("Received an unexpected URL from the web process: '%s'\n", url.string().utf8().data());
     return false;
 }
 
@@ -377,7 +377,7 @@ void WebProcessProxy::didClose(CoreIPC::Connection*)
 
 void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID)
 {
-    fprintf(stderr, "Received an invalid message from the web process with message ID %x\n", messageID.toInt());
+    WTFLogAlways("Received an invalid message from the web process with message ID %x\n", messageID.toInt());
 
     // Terminate the WebProcesses.
     terminate();
index b9973ad..c44bbbb 100644 (file)
@@ -41,7 +41,7 @@ bool InjectedBundle::load(APIObject* initializationUserData)
 {
     if (m_sandboxExtension) {
         if (!m_sandboxExtension->consume()) {
-            fprintf(stderr, "InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
+            WTFLogAlways("InjectedBundle::load failed - Could not consume bundle sandbox extension for [%s].\n", m_path.utf8().data());
             return false;
         }
 
@@ -50,30 +50,30 @@ bool InjectedBundle::load(APIObject* initializationUserData)
     
     RetainPtr<CFStringRef> injectedBundlePathStr(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(m_path.characters()), m_path.length()));
     if (!injectedBundlePathStr) {
-        fprintf(stderr, "InjectedBundle::load failed - Could not create the path string.\n");
+        WTFLogAlways("InjectedBundle::load failed - Could not create the path string.\n");
         return false;
     }
     
     RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(0, injectedBundlePathStr.get(), kCFURLPOSIXPathStyle, false));
     if (!bundleURL) {
-        fprintf(stderr, "InjectedBundle::load failed - Could not create the url from the path string.\n");
+        WTFLogAlways("InjectedBundle::load failed - Could not create the url from the path string.\n");
         return false;
     }
 
     m_platformBundle = CFBundleCreate(0, bundleURL.get());
     if (!m_platformBundle) {
-        fprintf(stderr, "InjectedBundle::load failed - Could not create the bundle.\n");
+        WTFLogAlways("InjectedBundle::load failed - Could not create the bundle.\n");
         return false;
     }
         
     if (!CFBundleLoadExecutable(m_platformBundle)) {
-        fprintf(stderr, "InjectedBundle::load failed - Could not load the executable from the bundle.\n");
+        WTFLogAlways("InjectedBundle::load failed - Could not load the executable from the bundle.\n");
         return false;
     }
 
     WKBundleInitializeFunctionPtr initializeFunction = reinterpret_cast<WKBundleInitializeFunctionPtr>(CFBundleGetFunctionPointerForName(m_platformBundle, CFSTR("WKBundleInitialize")));
     if (!initializeFunction) {
-        fprintf(stderr, "InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
+        WTFLogAlways("InjectedBundle::load failed - Could not find the initialize function in the bundle executable.\n");
         return false;
     }
 
index 9ea4b55..f2386c4 100644 (file)
@@ -63,19 +63,19 @@ static CString readSandboxProfile()
     RetainPtr<CFURLRef> profileURL(AdoptCF, CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("com.apple.WebKit.PluginProcess"), CFSTR("sb"), 0));
     char profilePath[PATH_MAX];
     if (!CFURLGetFileSystemRepresentation(profileURL.get(), false, reinterpret_cast<UInt8*>(profilePath), sizeof(profilePath))) {
-        fprintf(stderr, "Could not get file system representation of plug-in sandbox URL\n");
+        WTFLogAlways("Could not get file system representation of plug-in sandbox URL\n");
         return CString();
     }
 
     FILE *file = fopen(profilePath, "r");
     if (!file) {
-        fprintf(stderr, "Could not open plug-in sandbox file '%s'\n", profilePath);
+        WTFLogAlways("Could not open plug-in sandbox file '%s'\n", profilePath);
         return CString();
     }
 
     struct stat fileInfo;
     if (stat(profilePath, &fileInfo)) {
-        fprintf(stderr, "Could not get plug-in sandbox file size '%s'\n", profilePath);
+        WTFLogAlways("Could not get plug-in sandbox file size '%s'\n", profilePath);
         return CString();
     }
 
@@ -83,7 +83,7 @@ static CString readSandboxProfile()
     CString result = CString::newUninitialized(fileInfo.st_size, characterBuffer);
 
     if (1 != fread(characterBuffer, fileInfo.st_size, 1, file)) {
-        fprintf(stderr, "Could not read plug-in sandbox file '%s'\n", profilePath);
+        WTFLogAlways("Could not read plug-in sandbox file '%s'\n", profilePath);
         return CString();
     }
 
@@ -107,7 +107,7 @@ NPError WKN_EnterSandbox(const char* readOnlyPaths[], const char* readWritePaths
     setenv("DIRHELPER_USER_DIR_SUFFIX", fileSystemRepresentation(systemDirectorySuffix).data(), 0);
     char temporaryDirectory[PATH_MAX];
     if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
-        fprintf(stderr, "PluginProcess: couldn't retrieve private temporary directory path: %d\n", errno);
+        WTFLogAlways("PluginProcess: couldn't retrieve private temporary directory path: %d\n", errno);
         exit(EX_NOPERM);
     }
     setenv("TMPDIR", temporaryDirectory, 1);
@@ -156,12 +156,12 @@ NPError WKN_EnterSandbox(const char* readOnlyPaths[], const char* readWritePaths
     const char* sandboxParameters[] = { "HOME_DIR", homeDirectory, 0, 0 };
 
     if (!WKEnterPluginSandbox(profile.data(), sandboxParameters, extendedReadOnlyPaths.data(), extendedReadWritePaths.data())) {
-        fprintf(stderr, "Couldn't initialize sandbox profile\n");
+        WTFLogAlways("Couldn't initialize sandbox profile\n");
         exit(EX_NOPERM);
     }
 
     if (noErr != WKEnableSandboxStyleFileQuarantine()) {
-        fprintf(stderr, "Couldn't enable file quarantine\n");
+        WTFLogAlways("Couldn't enable file quarantine\n");
         exit(EX_NOPERM);
     }
 
index ee17567..396e895 100644 (file)
@@ -175,7 +175,7 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
 {
 #if ENABLE(WEB_PROCESS_SANDBOX)
     if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisableSandbox"]) {
-        fprintf(stderr, "Bypassing sandbox due to DisableSandbox user default.\n");
+        WTFLogAlways("Bypassing sandbox due to DisableSandbox user default.\n");
         return;
     }
 
@@ -185,7 +185,7 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
     setenv("DIRHELPER_USER_DIR_SUFFIX", fileSystemRepresentation(systemDirectorySuffix).data(), 0);
     char temporaryDirectory[PATH_MAX];
     if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
-        fprintf(stderr, "WebProcess: couldn't retrieve private temporary directory path: %d\n", errno);
+        WTFLogAlways("WebProcess: couldn't retrieve private temporary directory path: %d\n", errno);
         exit(EX_NOPERM);
     }
     setenv("TMPDIR", temporaryDirectory, 1);
@@ -215,9 +215,9 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
 
     char* errorBuf;
     if (sandbox_init_with_parameters(profilePath, SANDBOX_NAMED_EXTERNAL, sandboxParameters.data(), &errorBuf)) {
-        fprintf(stderr, "WebProcess: couldn't initialize sandbox profile [%s]\n", profilePath);
+        WTFLogAlways("WebProcess: couldn't initialize sandbox profile [%s]\n", profilePath);
         for (size_t i = 0; sandboxParameters[i]; i += 2)
-            fprintf(stderr, "%s=%s\n", sandboxParameters[i], sandboxParameters[i + 1]);
+            WTFLogAlways("%s=%s\n", sandboxParameters[i], sandboxParameters[i + 1]);
         exit(EX_NOPERM);
     }
 
@@ -227,7 +227,7 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
     // This will override LSFileQuarantineEnabled from Info.plist unless sandbox quarantine is globally disabled.
     OSStatus error = WKEnableSandboxStyleFileQuarantine();
     if (error) {
-        fprintf(stderr, "WebProcess: couldn't enable sandbox style file quarantine: %ld\n", (long)error);
+        WTFLogAlways("WebProcess: couldn't enable sandbox style file quarantine: %ld\n", (long)error);
         exit(EX_NOPERM);
     }
 #endif
index 4e2b155..2dfcef2 100644 (file)
@@ -84,7 +84,7 @@ int WebProcessMain(const CommandLine& commandLine)
     if (clientExecutable.isEmpty()) {
         kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort);
         if (kr) {
-            fprintf(stderr, "bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
+            WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr);
             return 2;
         }
     }
@@ -96,7 +96,7 @@ int WebProcessMain(const CommandLine& commandLine)
         // Make it possible to look up.
         serviceName = String::format("com.apple.WebKit.WebProcess-%d", getpid());
         if (kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.utf8().data()), publishedService, 0)) {
-            fprintf(stderr, "Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr);
+            WTFLogAlways("Failed to register service name \"%s\". %s (%x)\n", serviceName.utf8().data(), mach_error_string(kr), kr);
             return EXIT_FAILURE;
         }
 
@@ -123,7 +123,7 @@ int WebProcessMain(const CommandLine& commandLine)
 
         mach_msg_empty_rcv_t message;
         if (kern_return_t kr = mach_msg(&message.header, MACH_RCV_MSG, 0, sizeof(message), publishedService, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL)) {
-            fprintf(stderr, "Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr);
+            WTFLogAlways("Failed to receive port from the UI process. %s (%x)\n", mach_error_string(kr), kr);
             return EXIT_FAILURE;
         }
 
@@ -132,7 +132,7 @@ int WebProcessMain(const CommandLine& commandLine)
         mach_port_type_t portType;
         kern_return_t kr = mach_port_type(mach_task_self(), serverPort, &portType);
         if (kr || !(portType & MACH_PORT_TYPE_SEND)) {
-            fprintf(stderr, "Failed to obtain send right for port received from the UI process.\n");
+            WTFLogAlways("Failed to obtain send right for port received from the UI process.\n");
             return EXIT_FAILURE;
         }
     }