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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 2651843003: DevTools: update console timestamp style (Closed)
Patch Set: ac Created 3 years, 11 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: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
index 368bce0f601c397bd11c32bc910e31eaa0b388a2..283c5f1fada945b7c798a10b3ac5ee3442791dc7 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -816,23 +816,49 @@ Console.ConsoleViewMessage = class {
}
/**
- * @param {boolean} show
+ * @param {!Console.ConsoleViewMessage.TimestampFormat} format
*/
- updateTimestamp(show) {
+ updateTimestamp(format) {
dgozman 2017/01/25 00:51:46 Instead of passing format, grab it from the settin
luoe 2017/01/25 19:43:21 Done.
if (!this._contentElement)
return;
- if (show && !this.timestampElement) {
- this.timestampElement = createElementWithClass('span', 'console-timestamp');
- this.timestampElement.textContent = (new Date(this._message.timestamp)).toConsoleTime() + ' ';
+ if (format !== Console.ConsoleViewMessage.TimestampFormat.None) {
+ var timestampText = formatTimestamp(this._message.timestamp, format);
+ if (!this.timestampElement)
dgozman 2017/01/25 00:51:46 _timestampElement
luoe 2017/01/25 19:43:21 Done.
+ this.timestampElement = createElementWithClass('span', 'console-timestamp');
+ this.timestampElement.textContent = timestampText + ' ';
+ this.timestampElement.title = timestampText;
this._contentElement.insertBefore(this.timestampElement, this._contentElement.firstChild);
- return;
- }
-
- if (!show && this.timestampElement) {
+ } else if (this.timestampElement) {
this.timestampElement.remove();
delete this.timestampElement;
}
+
+ /**
+ * @param {number} timestamp
+ * @param {!Console.ConsoleViewMessage.TimestampFormat} format
+ * @return {string}
+ */
+ function formatTimestamp(timestamp, format) {
+ var date = new Date(timestamp);
+ var yymmdd = date.getFullYear() + '-' + leadZero(date.getMonth() + 1, 2) + '-' + leadZero(date.getDate(), 2);
+ var hhmmssfff = leadZero(date.getHours(), 2) + ':' + leadZero(date.getMinutes(), 2) + ':' +
+ leadZero(date.getSeconds(), 2) + '.' + leadZero(date.getMilliseconds(), 3);
+ if (format === Console.ConsoleViewMessage.TimestampFormat.Full)
+ return yymmdd + ' ' + hhmmssfff;
+ return hhmmssfff;
+
+ /**
+ * @param {number} value
+ * @param {number} length
+ * @return {string}
+ */
+ function leadZero(value, length) {
+ var valueString = value.toString();
+ var padding = length - valueString.length;
+ return padding <= 0 ? valueString : '0'.repeat(padding) + valueString;
+ }
+ }
}
/**
@@ -895,7 +921,7 @@ Console.ConsoleViewMessage = class {
formattedMessage = this._buildMessage(consoleMessage);
contentElement.appendChild(formattedMessage);
- this.updateTimestamp(Common.moduleSetting('consoleTimestampsEnabled').get());
+ this.updateTimestamp(Common.moduleSetting('consoleTimestampFormat').get());
return this._contentElement;
}
@@ -983,6 +1009,8 @@ Console.ConsoleViewMessage = class {
return;
this._repeatCountElement.remove();
+ if (this._contentElement)
+ this._contentElement.classList.remove('repeated-message');
delete this._repeatCountElement;
}
@@ -1169,6 +1197,15 @@ Console.ConsoleViewMessage = class {
};
/**
+ * @enum {string}
+ */
+Console.ConsoleViewMessage.TimestampFormat = {
+ None: 'none',
+ Full: 'full',
+ Short: 'short'
+};
+
+/**
* @unrestricted
*/
Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage {

Powered by Google App Engine
This is Rietveld 408576698