Bug 131050

Summary: Web Inspector: Provide a way for JSContext console to log to system console
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, graouts, joepeck, mark.lam, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix
timothy: review+, joepeck: commit-queue-
[PATCH] Revised none

Joseph Pecoraro
Reported 2014-04-01 11:52:08 PDT
We already have a way for a Page's console to log to the system console. We should provide a way for this to work with JSContext's console. An application user default seems reasonable. We could also make API/SPI to toggle at runtime.
Attachments
[PATCH] Proposed Fix (6.08 KB, patch)
2014-04-01 12:03 PDT, Joseph Pecoraro
timothy: review+
joepeck: commit-queue-
[PATCH] Revised (11.22 KB, patch)
2014-04-03 14:57 PDT, Joseph Pecoraro
no flags
Radar WebKit Bug Importer
Comment 1 2014-04-01 11:53:30 PDT
Joseph Pecoraro
Comment 2 2014-04-01 12:03:49 PDT
Created attachment 228304 [details] [PATCH] Proposed Fix cq- because I haven't tested with iOS yet and I'm not sure if printf will work. It works on OS X though, so getting the general idea reviewed.
WebKit Commit Bot
Comment 3 2014-04-01 12:05:31 PDT
Attachment 228304 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/inspector/JSConsoleClient.cpp:73: Missing space before { [whitespace/braces] [5] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Timothy Hatcher
Comment 4 2014-04-01 12:14:48 PDT
Comment on attachment 228304 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=228304&action=review > Source/JavaScriptCore/inspector/JSConsoleClient.cpp:62 > + Boolean preference = CFPreferencesGetAppBooleanValue(CFSTR("JavaScriptCoreConsoleLogToSystemConsole"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); JavaScriptCoreConsoleLogToSystemConsole implies only console.log is printed. A verb like "output" would help too. Maybe: OutputJavaScriptCoreConsoleToSystemConsole. Does this work for WebKit too? Maybe OutputJavaScriptConsoleToSystemConsole if so. > Source/JavaScriptCore/inspector/JSConsoleClient.cpp:82 > + if (JSConsoleClient::logToSystemConsole()) No need for JSConsoleClient:: right?
Joseph Pecoraro
Comment 5 2014-04-01 13:23:32 PDT
(In reply to comment #4) > (From update of attachment 228304 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=228304&action=review > > > Source/JavaScriptCore/inspector/JSConsoleClient.cpp:62 > > + Boolean preference = CFPreferencesGetAppBooleanValue(CFSTR("JavaScriptCoreConsoleLogToSystemConsole"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); > > JavaScriptCoreConsoleLogToSystemConsole implies only console.log is printed. A verb like "output" would help too. Maybe: OutputJavaScriptCoreConsoleToSystemConsole. Does this work for WebKit too? Maybe OutputJavaScriptConsoleToSystemConsole if so. I want the preference to start with "JavaScriptCore" as a namespacing thing. There is one other CFPreference in JavaScriptCore and it does the same. Any preference among these? - "JavaScriptCoreOutputConsoleMessagesToSystemConsole" - "JavaScriptCoreLogConsoleMessagesToSystemConsole" - "JavaScriptCoreConsoleLogToSystemConsoleEnabled" > > Source/JavaScriptCore/inspector/JSConsoleClient.cpp:82 > > + if (JSConsoleClient::logToSystemConsole()) > > No need for JSConsoleClient:: right? Correct, but I prefer the explicit prefix because it makes it obvious that this is a static/class function and not a member function. If we have a style one way or the other I can match.
Timothy Hatcher
Comment 6 2014-04-01 13:32:47 PDT
Comment on attachment 228304 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=228304&action=review >>> Source/JavaScriptCore/inspector/JSConsoleClient.cpp:62 >>> + Boolean preference = CFPreferencesGetAppBooleanValue(CFSTR("JavaScriptCoreConsoleLogToSystemConsole"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); >> >> JavaScriptCoreConsoleLogToSystemConsole implies only console.log is printed. A verb like "output" would help too. Maybe: OutputJavaScriptCoreConsoleToSystemConsole. Does this work for WebKit too? Maybe OutputJavaScriptConsoleToSystemConsole if so. > > I want the preference to start with "JavaScriptCore" as a namespacing thing. There is one other CFPreference in JavaScriptCore and it does the same. > > Any preference among these? > > - "JavaScriptCoreOutputConsoleMessagesToSystemConsole" > - "JavaScriptCoreLogConsoleMessagesToSystemConsole" > - "JavaScriptCoreConsoleLogToSystemConsoleEnabled" Prefixing with JSC makes sense. I like JavaScriptCoreOutputConsoleMessagesToSystemConsole. >>> Source/JavaScriptCore/inspector/JSConsoleClient.cpp:82 >>> + if (JSConsoleClient::logToSystemConsole()) >> >> No need for JSConsoleClient:: right? > > Correct, but I prefer the explicit prefix because it makes it obvious that this is a static/class function and not a member function. If we have a style one way or the other I can match. It looks like you are calling a base class method with this syntax. I know I have seen other static methods called without a prefix in WebCore. Not sure there is a formal style guide.
Joseph Pecoraro
Comment 7 2014-04-03 14:57:12 PDT
Created attachment 228546 [details] [PATCH] Revised This refactors all the printfs instead StringBuilder + WTFLogAlways. It also includes the updated default name. I tested on iOS this works (the printf would have too, but I think this is nicer).
WebKit Commit Bot
Comment 8 2014-04-03 14:58:52 PDT
Attachment 228546 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/inspector/JSConsoleClient.cpp:73: Missing space before { [whitespace/braces] [5] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Timothy Hatcher
Comment 9 2014-04-04 12:26:56 PDT
Comment on attachment 228546 [details] [PATCH] Revised View in context: https://bugs.webkit.org/attachment.cgi?id=228546&action=review > Source/JavaScriptCore/inspector/JSConsoleClient.cpp:75 > + static std::once_flag initializeLogging; > + std::call_once(initializeLogging, []{ > + JSConsoleClient::initializeLogToSystemConsole(); > + }); This makes the default behave differently than the WebKit2 equivalent setting. It can only be changed between executions, not while the app is running. That seems fine, but it might be limiting if an app needed to change it at runtime (like with a command line flag or checkbox.) The solution would require always calling CFPreferencesGetAppBooleanValue, or exposing a JSC API to change it at runtime. We can cross that bridge when needed.
WebKit Commit Bot
Comment 10 2014-04-04 12:58:13 PDT
Comment on attachment 228546 [details] [PATCH] Revised Clearing flags on attachment: 228546 Committed r166799: <http://trac.webkit.org/changeset/166799>
WebKit Commit Bot
Comment 11 2014-04-04 12:58:18 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.