Title: [161678] trunk/Source/WebCore
Revision
161678
Author
[email protected]
Date
2014-01-10 14:16:17 -0800 (Fri, 10 Jan 2014)

Log Message

Clean up and fix some issues with stdout formatting of console messages.

* Fix URLs not printing line numbers unless column number is > 0.
* Change "CONSOLEAPI" to "CONSOLE" for the source.
* Clean up how console.trace outputs and print URL, line and column for each frame.
* Print "(unknown)" for anonymous and native code call frames.

https://bugs.webkit.org/show_bug.cgi?id=126767

Reviewed by Joseph Pecoraro.

* page/Console.cpp:
(WebCore::internalAddMessage):
* page/PageConsole.cpp:
(WebCore::PageConsole::printSourceURLAndPosition):
(WebCore::PageConsole::printMessageSourceAndLevelPrefix):
* page/PageConsole.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161677 => 161678)


--- trunk/Source/WebCore/ChangeLog	2014-01-10 22:13:07 UTC (rev 161677)
+++ trunk/Source/WebCore/ChangeLog	2014-01-10 22:16:17 UTC (rev 161678)
@@ -1,3 +1,23 @@
+2014-01-10  Timothy Hatcher  <[email protected]>
+
+        Clean up and fix some issues with stdout formatting of console messages.
+
+        * Fix URLs not printing line numbers unless column number is > 0.
+        * Change "CONSOLEAPI" to "CONSOLE" for the source.
+        * Clean up how console.trace outputs and print URL, line and column for each frame.
+        * Print "(unknown)" for anonymous and native code call frames.
+
+        https://bugs.webkit.org/show_bug.cgi?id=126767
+
+        Reviewed by Joseph Pecoraro.
+
+        * page/Console.cpp:
+        (WebCore::internalAddMessage):
+        * page/PageConsole.cpp:
+        (WebCore::PageConsole::printSourceURLAndPosition):
+        (WebCore::PageConsole::printMessageSourceAndLevelPrefix):
+        * page/PageConsole.h:
+
 2014-01-10  Joseph Pecoraro  <[email protected]>
 
         [iOS] Fill in missing WebCoreThread function pointers

Modified: trunk/Source/WebCore/page/Console.cpp (161677 => 161678)


--- trunk/Source/WebCore/page/Console.cpp	2014-01-10 22:13:07 UTC (rev 161677)
+++ trunk/Source/WebCore/page/Console.cpp	2014-01-10 22:16:17 UTC (rev 161678)
@@ -93,8 +93,11 @@
         return;
 
     PageConsole::printSourceURLAndPosition(lastCaller.sourceURL(), lastCaller.lineNumber());
-    PageConsole::printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level);
 
+    printf(": ");
+
+    PageConsole::printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level, printTrace);
+
     for (size_t i = 0; i < arguments->argumentCount(); ++i) {
         String argAsString = arguments->argumentAt(i).toString(arguments->globalState());
         printf(" %s", argAsString.utf8().data());
@@ -102,12 +105,21 @@
 
     printf("\n");
 
-    if (printTrace) {
-        printf("Stack Trace\n");
-        for (size_t i = 0; i < callStack->size(); ++i) {
-            String functionName = String(callStack->at(i).functionName());
-            printf("\t%s\n", functionName.utf8().data());
-        }
+    if (!printTrace)
+        return;
+
+    for (size_t i = 0; i < callStack->size(); ++i) {
+        const ScriptCallFrame& callFrame = callStack->at(i);
+
+        String functionName = String(callFrame.functionName());
+        if (functionName.isEmpty())
+            functionName = ASCIILiteral("(unknown)");
+
+        printf("%lu: %s (", i, functionName.utf8().data());
+
+        PageConsole::printSourceURLAndPosition(callFrame.sourceURL(), callFrame.lineNumber());
+
+        printf(")\n");
     }
 }
 

Modified: trunk/Source/WebCore/page/PageConsole.cpp (161677 => 161678)


--- trunk/Source/WebCore/page/PageConsole.cpp	2014-01-10 22:13:07 UTC (rev 161677)
+++ trunk/Source/WebCore/page/PageConsole.cpp	2014-01-10 22:16:17 UTC (rev 161678)
@@ -68,13 +68,15 @@
 {
     if (!sourceURL.isEmpty()) {
         if (lineNumber > 0 && columnNumber > 0)
-            printf("%s:%u:%u: ", sourceURL.utf8().data(), lineNumber, columnNumber);
+            printf("%s:%u:%u", sourceURL.utf8().data(), lineNumber, columnNumber);
+        else if (lineNumber > 0)
+            printf("%s:%u", sourceURL.utf8().data(), lineNumber);
         else
-            printf("%s: ", sourceURL.utf8().data());
+            printf("%s", sourceURL.utf8().data());
     }
 }
 
-void PageConsole::printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level)
+void PageConsole::printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel level, bool showAsTrace)
 {
     const char* sourceString;
     switch (source) {
@@ -88,7 +90,7 @@
         sourceString = "NETWORK";
         break;
     case ConsoleAPIMessageSource:
-        sourceString = "CONSOLEAPI";
+        sourceString = "CONSOLE";
         break;
     case StorageMessageSource:
         sourceString = "STORAGE";
@@ -134,6 +136,9 @@
         break;
     }
 
+    if (showAsTrace)
+        levelString = "TRACE";
+
     printf("%s %s:", sourceString, levelString);
 }
 

Modified: trunk/Source/WebCore/page/PageConsole.h (161677 => 161678)


--- trunk/Source/WebCore/page/PageConsole.h	2014-01-10 22:13:07 UTC (rev 161677)
+++ trunk/Source/WebCore/page/PageConsole.h	2014-01-10 22:16:17 UTC (rev 161678)
@@ -49,7 +49,7 @@
     ~PageConsole();
 
     static void printSourceURLAndPosition(const String& sourceURL, unsigned lineNumber, unsigned columnNumber = 0);
-    static void printMessageSourceAndLevelPrefix(MessageSource, MessageLevel);
+    static void printMessageSourceAndLevelPrefix(MessageSource, MessageLevel, bool showAsTrace = false);
 
     void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack> = 0, JSC::ExecState* = 0, unsigned long requestIdentifier = 0);
     void addMessage(MessageSource, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to