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

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

Issue 185713007: DevTools: Add timestamp support in the console (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/devtools/front_end/ConsoleView.js ('k') | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ConsoleViewMessage.js
diff --git a/Source/devtools/front_end/ConsoleViewMessage.js b/Source/devtools/front_end/ConsoleViewMessage.js
index 18f54e27ffa3d8275ec9a5b94247573f2ec6f2e8..ccbf23e5c1ece83ad7d301d88989039e657deb4d 100644
--- a/Source/devtools/front_end/ConsoleViewMessage.js
+++ b/Source/devtools/front_end/ConsoleViewMessage.js
@@ -52,6 +52,8 @@ WebInspector.ConsoleViewMessage = function(target, consoleMessage, linkifier)
"node": this._formatParameterAsNode,
"string": this._formatParameterAsString
};
+
+ WebInspector.settings.consoleTimestampsEnabled.addChangeListener(this._consoleTimestampsSettingChanged, this);
}
WebInspector.ConsoleViewMessage.prototype = {
@@ -845,6 +847,29 @@ WebInspector.ConsoleViewMessage.prototype = {
return regexObject.test(this._formattedMessageText()) || (!!this._anchorElement && regexObject.test(this._anchorElement.textContent));
},
+ _updateTimestamp: function(show)
+ {
+ if (!this._element)
+ return;
+
+ if (show && !this.timestampElement) {
+ this.timestampElement = this._element.createChild("span", "console-timestamp");
+ this.timestampElement.textContent = (new Date(this._message.timestamp)).toConsoleTime();
+ var afterRepeatCountChild = this.repeatCountElement && this.repeatCountElement.nextSibling;
+ this._element.insertBefore(this.timestampElement, afterRepeatCountChild || this._element.firstChild);
+ return;
+ }
+
+ if (!show && this.timestampElement)
+ this.timestampElement.remove();
+ },
+
+ _consoleTimestampsSettingChanged: function(event)
+ {
+ var enabled = /** @type {boolean} */ (event.data);
+ this._updateTimestamp(enabled);
+ },
+
/**
* @return {!Element}
*/
@@ -885,6 +910,8 @@ WebInspector.ConsoleViewMessage.prototype = {
if (this._repeatCount > 1)
this._showRepeatCountElement();
+ this._updateTimestamp(WebInspector.settings.consoleTimestampsEnabled.get());
+
return element;
},
« no previous file with comments | « Source/devtools/front_end/ConsoleView.js ('k') | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698