Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1123)

Unified Diff: Source/devtools/front_end/ConsoleModel.js

Issue 185713007: DevTools: Add timestamp support in the console (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed apavlov's comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/ConsoleModel.js
diff --git a/Source/devtools/front_end/ConsoleModel.js b/Source/devtools/front_end/ConsoleModel.js
index 67eb4068a67d69776ff5433bbf93d6559db1ff50..81ded22bf248002804008c22146ead780ea2d2bf 100644
--- a/Source/devtools/front_end/ConsoleModel.js
+++ b/Source/devtools/front_end/ConsoleModel.js
@@ -39,7 +39,6 @@ WebInspector.ConsoleModel = function(target)
this.messages = [];
this.warnings = 0;
this.errors = 0;
- this._interruptRepeatCount = false;
this._target = target;
this._consoleAgent = target.consoleAgent();
target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this));
@@ -94,16 +93,31 @@ WebInspector.ConsoleModel.prototype = {
if (isFromBackend && WebInspector.SourceMap.hasSourceMapRequestHeader(msg.request))
return;
- msg.index = this.messages.length;
- this.messages.push(msg);
- this._incrementErrorWarningCount(msg);
+ var interruptRepeatCount = !isFromBackend || WebInspector.settings.consoleTimestampsEnabled.get();
- if (isFromBackend)
- this._previousMessage = msg;
-
- this._interruptRepeatCount = !isFromBackend;
+ /**
+ * @param {?WebInspector.ConsoleMessage} msg
+ * @return {boolean}
+ */
+ function isGroupMessage(msg)
+ {
+ return !!msg && ((msg.type === WebInspector.ConsoleMessage.MessageType.StartGroup)
+ || (msg.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed)
+ || (msg.type === WebInspector.ConsoleMessage.MessageType.EndGroup));
+ }
- this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded, msg);
+ if (!interruptRepeatCount && !isGroupMessage(this._previousMessage) && msg.isEqual(this._previousMessage)) {
+ this._previousMessage.timestamp = msg.timestamp;
+ this._previousMessage.repeatCount += 1;
+ this._incrementErrorWarningCount(this._previousMessage);
+ this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.RepeatCountUpdated, this._previousMessage);
+ } else {
+ msg.index = this.messages.length;
+ this.messages.push(msg);
+ this._incrementErrorWarningCount(msg);
+ this._previousMessage = msg;
+ this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded, msg);
+ }
},
/**
@@ -185,10 +199,10 @@ WebInspector.ConsoleModel.prototype = {
{
switch (msg.level) {
case WebInspector.ConsoleMessage.MessageLevel.Warning:
- this.warnings += msg.repeatDelta;
+ this.warnings += 1;
break;
case WebInspector.ConsoleMessage.MessageLevel.Error:
- this.errors += msg.repeatDelta;
+ this.errors += 1;
break;
}
},
@@ -210,33 +224,6 @@ WebInspector.ConsoleModel.prototype = {
this.warnings = 0;
},
- /**
- * @param {number} count
- */
- _messageRepeatCountUpdated: function(count)
- {
- var msg = this._previousMessage;
- if (!msg)
- return;
-
- var prevRepeatCount = msg.totalRepeatCount;
-
- if (!this._interruptRepeatCount) {
- msg.repeatDelta = count - prevRepeatCount;
- msg.repeatCount = msg.repeatCount + msg.repeatDelta;
- msg.totalRepeatCount = count;
-
- this._incrementErrorWarningCount(msg);
- this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.RepeatCountUpdated, msg);
- } else {
- var msgCopy = msg.clone();
- msgCopy.totalRepeatCount = count;
- msgCopy.repeatCount = (count - prevRepeatCount) || 1;
- msgCopy.repeatDelta = msgCopy.repeatCount;
- this.addMessage(msgCopy, true);
- }
- },
-
__proto__: WebInspector.Object.prototype
}
@@ -269,13 +256,13 @@ WebInspector.ConsoleModel.UIDelegate.prototype = {
* @param {?string=} url
* @param {number=} line
* @param {number=} column
- * @param {number=} repeatCount
* @param {!NetworkAgent.RequestId=} requestId
* @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
* @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace
+ * @param {number=} timestamp
* @param {boolean=} isOutdated
*/
-WebInspector.ConsoleMessage = function(source, level, messageText, type, url, line, column, repeatCount, requestId, parameters, stackTrace, isOutdated)
+WebInspector.ConsoleMessage = function(source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated)
{
this.source = source;
this.level = level;
@@ -286,12 +273,10 @@ WebInspector.ConsoleMessage = function(source, level, messageText, type, url, li
this.column = column || 0;
this.parameters = parameters;
this.stackTrace = stackTrace;
+ this.timestamp = timestamp || Date.now();
this.isOutdated = isOutdated;
- repeatCount = repeatCount || 1;
- this.repeatCount = repeatCount;
- this.repeatDelta = repeatCount;
- this.totalRepeatCount = repeatCount;
+ this.repeatCount = 1;
this.request = requestId ? WebInspector.networkLog.requestForId(requestId) : null;
}
@@ -317,10 +302,10 @@ WebInspector.ConsoleMessage.prototype = {
this.url,
this.line,
this.column,
- this.repeatCount,
this.request ? this.request.requestId : undefined,
this.parameters,
this.stackTrace,
+ this.timestamp,
this.isOutdated);
},
@@ -333,18 +318,32 @@ WebInspector.ConsoleMessage.prototype = {
if (!msg)
return false;
+ if (this.parameters) {
+ if (!msg.parameters)
+ return false;
+ var mine = this.parameters;
+ var other = msg.parameters;
+ if (mine.length !== other.length)
+ return false;
+ // Never treat objects as equal - their properties might change over time.
+ for (var i = 0; i < mine.length; ++i) {
+ if (WebInspector.RemoteObject.fromPayload(mine[i]).type === "object")
+ return false;
+ }
+ }
+
if (this.stackTrace) {
if (!msg.stackTrace)
return false;
- var l = this.stackTrace;
- var r = msg.stackTrace;
- if (l.length !== r.length)
+ var mine = this.stackTrace;
+ var other = msg.stackTrace;
+ if (mine.length !== other.length)
return false;
- for (var i = 0; i < l.length; i++) {
- if (l[i].url !== r[i].url ||
- l[i].functionName !== r[i].functionName ||
- l[i].lineNumber !== r[i].lineNumber ||
- l[i].columnNumber !== r[i].columnNumber)
+ for (var i = 0; i < mine.length; ++i) {
+ if (mine[i].url !== other[i].url ||
+ mine[i].functionName !== other[i].functionName ||
+ mine[i].lineNumber !== other[i].lineNumber ||
+ mine[i].columnNumber !== other[i].columnNumber)
return false;
}
}
@@ -432,22 +431,14 @@ WebInspector.ConsoleDispatcher.prototype = {
payload.url,
payload.line,
payload.column,
- payload.repeatCount,
payload.networkRequestId,
payload.parameters,
payload.stackTrace,
+ payload.timestamp * 1000, // Convert to ms.
this._console._enablingConsole);
this._console.addMessage(consoleMessage, true);
},
- /**
- * @param {number} count
- */
- messageRepeatCountUpdated: function(count)
- {
- this._console._messageRepeatCountUpdated(count);
- },
-
messagesCleared: function()
{
if (!WebInspector.settings.preserveConsoleLog.get())

Powered by Google App Engine
This is Rietveld 408576698