void FrameConsole::addMessage(MessageSource source, MessageLevel level, const String& message, const String& url, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack> callStack, ScriptState* scriptState, unsigned long requestIdentifier) { if (muteCount) return; // FIXME: This should not need to reach for the main-frame. // Inspector code should just take the current frame and know how to walk itself. ExecutionContext* context = m_frame.document(); if (!context) return; String messageURL; if (callStack) { messageURL = callStack->at(0).sourceURL(); InspectorInstrumentation::addMessageToConsole(context, source, LogMessageType, level, message, callStack, requestIdentifier); } else { messageURL = url; InspectorInstrumentation::addMessageToConsole(context, source, LogMessageType, level, message, url, lineNumber, columnNumber, scriptState, requestIdentifier); } if (source == CSSMessageSource) return; String stackTrace; if (callStack && m_frame.chromeClient().shouldReportDetailedMessageForSource(messageURL)) stackTrace = FrameConsole::formatStackTraceString(message, callStack); m_frame.chromeClient().addMessageToConsole(&m_frame, source, level, message, lineNumber, messageURL, stackTrace); }
void InspectorInstrumentation::addProfileImpl(InstrumentingAgents* instrumentingAgents, RefPtr<ScriptProfile> profile, PassRefPtr<ScriptCallStack> callStack) { if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent()) { const ScriptCallFrame& lastCaller = callStack->at(0); profilerAgent->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL()); } }
void Console::reportMessageToClient(MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack) { String stackTrace; if (m_frame->page()->chrome().client().shouldReportDetailedMessageForSource(callStack->at(0).sourceURL())) { RefPtr<ScriptCallStack> fullStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture); stackTrace = PageConsole::formatStackTraceString(message, fullStack); } m_frame->page()->chrome().client().addMessageToConsole(ConsoleAPIMessageSource, level, message, callStack->at(0).lineNumber(), callStack->at(0).sourceURL(), stackTrace); }
ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) : m_source(s) , m_type(t) , m_level(l) , m_message(m) , m_arguments(arguments) , m_line(0) , m_url() , m_repeatCount(1) { if (callStack && callStack->size()) { const ScriptCallFrame& frame = callStack->at(0); m_url = frame.sourceURL(); m_line = frame.lineNumber(); } m_callStack = callStack; }
String FrameConsole::formatStackTraceString(const String& originalMessage, PassRefPtr<ScriptCallStack> callStack) { StringBuilder stackTrace; for (size_t i = 0; i < callStack->size(); ++i) { const ScriptCallFrame& frame = callStack->at(i); stackTrace.append("\n at " + (frame.functionName().length() ? frame.functionName() : "(anonymous function)")); stackTrace.append(" ("); stackTrace.append(frame.sourceURL()); stackTrace.append(':'); stackTrace.append(String::number(frame.lineNumber())); stackTrace.append(':'); stackTrace.append(String::number(frame.columnNumber())); stackTrace.append(')'); } return stackTrace.toString(); }
ConsoleMessage::ConsoleMessage(bool, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier) : m_source(source) , m_type(type) , m_level(level) , m_message(message) , m_arguments(0) , m_line(0) , m_repeatCount(1) , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) { if (callStack && callStack->size()) { const ScriptCallFrame& frame = callStack->at(0); m_url = frame.sourceURL(); m_line = frame.lineNumber(); } m_callStack = callStack; }
void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCallStack> callStack) { // Follow Firebug's behavior of requiring a title that is not null or // undefined for timing functions if (title.isNull()) return; HashMap<String, double>::iterator it = m_times.find(title); if (it == m_times.end()) return; double startTime = it->second; m_times.remove(it); double elapsed = currentTime() * 1000 - startTime; String message = title + String::format(": %.0fms", elapsed); const ScriptCallFrame& lastCaller = callStack->at(0); addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lastCaller.sourceURL(), lastCaller.lineNumber()); }
void Console::profile(const String& title, ScriptState* state, PassRefPtr<ScriptCallStack> callStack) { Page* page = this->page(); if (!page) return; // FIXME: log a console message when profiling is disabled. if (!InspectorInstrumentation::profilerEnabled(page)) return; String resolvedTitle = title; if (title.isNull()) // no title so give it the next user initiated profile title. resolvedTitle = InspectorInstrumentation::getCurrentUserInitiatedProfileName(page, true); ScriptProfiler::start(state, resolvedTitle); const ScriptCallFrame& lastCaller = callStack->at(0); InspectorInstrumentation::addStartProfilingMessageToConsole(page, resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL()); }
void InspectorConsoleAgent::count(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack) { const ScriptCallFrame& lastCaller = callStack->at(0); // Follow Firebug's behavior of counting with null and undefined title in // the same bucket as no argument String title; arguments->getFirstArgumentAsString(title); String identifier = title + '@' + lastCaller.sourceURL() + ':' + String::number(lastCaller.lineNumber()); HashMap<String, unsigned>::iterator it = m_counts.find(identifier); int count; if (it == m_counts.end()) count = 1; else { count = it->second + 1; m_counts.remove(it); } m_counts.add(identifier, count); String message = title + ": " + String::number(count); addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lastCaller.sourceURL(), lastCaller.lineNumber()); }
void InspectorProfilerAgent::addProfile(PassRefPtr<ScriptProfile> prpProfile, PassRefPtr<ScriptCallStack> callStack) { const ScriptCallFrame& lastCaller = callStack->at(0); addProfile(prpProfile, lastCaller.lineNumber(), lastCaller.sourceURL()); }