Commit 3fc29bad authored by timothy@apple.com's avatar timothy@apple.com

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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161678 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3117564d
2014-01-10 Timothy Hatcher <timothy@apple.com>
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 <pecoraro@apple.com>
[iOS] Fill in missing WebCoreThread function pointers
......@@ -93,7 +93,10 @@ static void internalAddMessage(Page* page, MessageType type, MessageLevel level,
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());
......@@ -102,12 +105,21 @@ static void internalAddMessage(Page* page, MessageType type, MessageLevel level,
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");
}
}
......
......@@ -68,13 +68,15 @@ void PageConsole::printSourceURLAndPosition(const String& sourceURL, unsigned li
{
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 @@ void PageConsole::printMessageSourceAndLevelPrefix(MessageSource source, Message
sourceString = "NETWORK";
break;
case ConsoleAPIMessageSource:
sourceString = "CONSOLEAPI";
sourceString = "CONSOLE";
break;
case StorageMessageSource:
sourceString = "STORAGE";
......@@ -134,6 +136,9 @@ void PageConsole::printMessageSourceAndLevelPrefix(MessageSource source, Message
break;
}
if (showAsTrace)
levelString = "TRACE";
printf("%s %s:", sourceString, levelString);
}
......
......@@ -49,7 +49,7 @@ public:
~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>);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment