OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu ments = false, bool printTrace = false) | 62 static void internalAddMessage(Page* page, MessageType type, MessageLevel level, ScriptState* state, PassRefPtr<ScriptArguments> prpArguments, bool acceptNoArgu ments = false, bool printTrace = false) |
63 { | 63 { |
64 RefPtr<ScriptArguments> arguments = prpArguments; | 64 RefPtr<ScriptArguments> arguments = prpArguments; |
65 | 65 |
66 if (!page) | 66 if (!page) |
67 return; | 67 return; |
68 | 68 |
69 if (!acceptNoArguments && !arguments->argumentCount()) | 69 if (!acceptNoArguments && !arguments->argumentCount()) |
70 return; | 70 return; |
71 | 71 |
72 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; | |
73 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize)); | |
74 const ScriptCallFrame& lastCaller = callStack->at(0); | |
75 | |
76 String message; | 72 String message; |
77 bool gotMessage = arguments->getFirstArgumentAsString(message); | 73 bool gotMessage = arguments->getFirstArgumentAsString(message); |
78 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); | 74 InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments); |
79 | 75 |
80 if (gotMessage) | 76 if (gotMessage) { |
81 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty pe, level, message, lastCaller.lineNumber(), lastCaller.sourceURL()); | 77 RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, 1)); |
78 if (page->chrome().client()->shouldReportDetailedMessageForSource(callSt ack->at(0).sourceURL())) { | |
pfeldman
2013/08/08 17:13:52
Is it true that you are now collecting stack trace
Devlin
2013/08/12 16:09:41
Short answer: Nope.
Sorry, I didn't upload the co
pfeldman
2013/08/12 16:15:34
Ok!
| |
79 callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeT oCapture); | |
80 for (size_t i = 0; i < callStack->size(); ++i) { | |
81 const ScriptCallFrame& frame = callStack->at(i); | |
82 message.append("\n at " + (frame.functionName().length() ? fr ame.functionName() : String("(anonymous function)")) + " (" + frame.sourceURL() + ":" + String::number(frame.lineNumber()) + ":" + String::number(frame.columnNu mber()) + ")"); | |
83 } | |
84 } | |
85 page->chrome().client()->addMessageToConsole(ConsoleAPIMessageSource, ty pe, level, message, callStack->at(0).lineNumber(), callStack->at(0).sourceURL()) ; | |
86 } | |
82 } | 87 } |
83 | 88 |
84 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 89 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
85 { | 90 { |
86 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts); | 91 internalAddMessage(page(), LogMessageType, DebugMessageLevel, state, argumen ts); |
87 } | 92 } |
88 | 93 |
89 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) | 94 void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments) |
90 { | 95 { |
91 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts); | 96 internalAddMessage(page(), LogMessageType, ErrorMessageLevel, state, argumen ts); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 } | 235 } |
231 | 236 |
232 Page* Console::page() const | 237 Page* Console::page() const |
233 { | 238 { |
234 if (!m_frame) | 239 if (!m_frame) |
235 return 0; | 240 return 0; |
236 return m_frame->page(); | 241 return m_frame->page(); |
237 } | 242 } |
238 | 243 |
239 } // namespace WebCore | 244 } // namespace WebCore |
OLD | NEW |