diff --git a/front_end/console/ConsoleViewMessage.js b/front_end/console/ConsoleViewMessage.js index de5cc8f1c0..6f74138c93 100644 --- a/front_end/console/ConsoleViewMessage.js +++ b/front_end/console/ConsoleViewMessage.js @@ -154,7 +154,7 @@ WebInspector.ConsoleViewMessage.prototype = { if (consoleMessage.source === WebInspector.ConsoleMessage.MessageSource.ConsoleAPI) { switch (consoleMessage.type) { case WebInspector.ConsoleMessage.MessageType.Trace: - this._messageElement = this._format(consoleMessage.parameters || ["console.trace()"]); + this._messageElement = this._format(consoleMessage.parameters || ["console.trace"]); break; case WebInspector.ConsoleMessage.MessageType.Clear: this._messageElement = createTextNode(WebInspector.UIString("Console was cleared")); @@ -1114,6 +1114,18 @@ WebInspector.ConsoleViewMessage.prototype = { case WebInspector.ConsoleMessage.MessageType.Log: typeString = "Log"; break; + case WebInspector.ConsoleMessage.MessageType.Debug: + typeString = "Debug"; + break; + case WebInspector.ConsoleMessage.MessageType.Info: + typeString = "Info"; + break; + case WebInspector.ConsoleMessage.MessageType.Error: + typeString = "Error"; + break; + case WebInspector.ConsoleMessage.MessageType.Warning: + typeString = "Warning"; + break; case WebInspector.ConsoleMessage.MessageType.Dir: typeString = "Dir"; break; diff --git a/front_end/sdk/ConsoleModel.js b/front_end/sdk/ConsoleModel.js index 4dd24af5f8..935eb7e23e 100644 --- a/front_end/sdk/ConsoleModel.js +++ b/front_end/sdk/ConsoleModel.js @@ -480,6 +480,10 @@ WebInspector.ConsoleMessage.MessageSource = { */ WebInspector.ConsoleMessage.MessageType = { Log: "log", + Debug: "debug", + Info: "info", + Error: "error", + Warning: "warning", Dir: "dir", DirXML: "dirxml", Table: "table", @@ -534,6 +538,8 @@ WebInspector.ConsoleDispatcher.prototype = { */ messageAdded: function(payload) { + if (payload.source === WebInspector.ConsoleMessage.MessageSource.ConsoleAPI) + return; var consoleMessage = new WebInspector.ConsoleMessage( this._console.target(), payload.source, diff --git a/front_end/sdk/RuntimeModel.js b/front_end/sdk/RuntimeModel.js index bf764a5209..ba2ab8420c 100644 --- a/front_end/sdk/RuntimeModel.js +++ b/front_end/sdk/RuntimeModel.js @@ -410,6 +410,49 @@ WebInspector.RuntimeDispatcher.prototype = { this._runtimeModel.target().consoleModel.addMessage(consoleMessage); }, + /** + * @override + * @param {string} type + * @param {!Array.} args + * @param {number} executionContextId + * @param {number} timestamp + * @param {!RuntimeAgent.StackTrace=} stackTrace + */ + consoleAPICalled: function(type, args, executionContextId, timestamp, stackTrace) + { + var level = WebInspector.ConsoleMessage.MessageLevel.Log; + if (type === WebInspector.ConsoleMessage.MessageType.Debug) + level = WebInspector.ConsoleMessage.MessageLevel.Debug; + if (type === WebInspector.ConsoleMessage.MessageType.Error || type === WebInspector.ConsoleMessage.MessageType.Assert) + level = WebInspector.ConsoleMessage.MessageLevel.Error; + if (type === WebInspector.ConsoleMessage.MessageType.Warning) + level = WebInspector.ConsoleMessage.MessageLevel.Warning; + if (type === WebInspector.ConsoleMessage.MessageType.Info) + level = WebInspector.ConsoleMessage.MessageLevel.Info; + var message = ""; + if (args.length && typeof args[0].value === "string") + message = args[0].value; + else if (args.length && args[0].description) + message = args[0].description; + var callFrame = stackTrace && stackTrace.callFrames.length ? stackTrace.callFrames[0] : null; + var consoleMessage = new WebInspector.ConsoleMessage( + this._runtimeModel.target(), + WebInspector.ConsoleMessage.MessageSource.ConsoleAPI, + level, + /** @type {string} */ (message), + type, + callFrame ? callFrame.url : undefined, + callFrame ? callFrame.lineNumber + 1 : undefined, + callFrame ? callFrame.columnNumber + 1 : undefined, + undefined, + args, + stackTrace, + timestamp, + executionContextId, + undefined); + this._runtimeModel.target().consoleModel.addMessage(consoleMessage); + }, + /** * @override * @param {!RuntimeAgent.RemoteObject} payload