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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 /** 809 /**
810 * @return {boolean} 810 * @return {boolean}
811 */ 811 */
812 matchesFilterRegex(regexObject) { 812 matchesFilterRegex(regexObject) {
813 regexObject.lastIndex = 0; 813 regexObject.lastIndex = 0;
814 var text = this.contentElement().deepTextContent(); 814 var text = this.contentElement().deepTextContent();
815 return regexObject.test(text); 815 return regexObject.test(text);
816 } 816 }
817 817
818 /** 818 /**
819 * @param {boolean} show 819 * @param {!Console.ConsoleViewMessage.TimestampFormat} format
820 */ 820 */
821 updateTimestamp(show) { 821 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.
822 if (!this._contentElement) 822 if (!this._contentElement)
823 return; 823 return;
824 824
825 if (show && !this.timestampElement) { 825 if (format !== Console.ConsoleViewMessage.TimestampFormat.None) {
826 this.timestampElement = createElementWithClass('span', 'console-timestamp' ); 826 var timestampText = formatTimestamp(this._message.timestamp, format);
827 this.timestampElement.textContent = (new Date(this._message.timestamp)).to ConsoleTime() + ' '; 827 if (!this.timestampElement)
dgozman 2017/01/25 00:51:46 _timestampElement
luoe 2017/01/25 19:43:21 Done.
828 this.timestampElement = createElementWithClass('span', 'console-timestam p');
829 this.timestampElement.textContent = timestampText + ' ';
830 this.timestampElement.title = timestampText;
828 this._contentElement.insertBefore(this.timestampElement, this._contentElem ent.firstChild); 831 this._contentElement.insertBefore(this.timestampElement, this._contentElem ent.firstChild);
829 return; 832 } else if (this.timestampElement) {
833 this.timestampElement.remove();
834 delete this.timestampElement;
830 } 835 }
831 836
832 if (!show && this.timestampElement) { 837 /**
833 this.timestampElement.remove(); 838 * @param {number} timestamp
834 delete this.timestampElement; 839 * @param {!Console.ConsoleViewMessage.TimestampFormat} format
840 * @return {string}
841 */
842 function formatTimestamp(timestamp, format) {
843 var date = new Date(timestamp);
844 var yymmdd = date.getFullYear() + '-' + leadZero(date.getMonth() + 1, 2) + '-' + leadZero(date.getDate(), 2);
845 var hhmmssfff = leadZero(date.getHours(), 2) + ':' + leadZero(date.getMinu tes(), 2) + ':' +
846 leadZero(date.getSeconds(), 2) + '.' + leadZero(date.getMilliseconds() , 3);
847 if (format === Console.ConsoleViewMessage.TimestampFormat.Full)
848 return yymmdd + ' ' + hhmmssfff;
849 return hhmmssfff;
850
851 /**
852 * @param {number} value
853 * @param {number} length
854 * @return {string}
855 */
856 function leadZero(value, length) {
857 var valueString = value.toString();
858 var padding = length - valueString.length;
859 return padding <= 0 ? valueString : '0'.repeat(padding) + valueString;
860 }
835 } 861 }
836 } 862 }
837 863
838 /** 864 /**
839 * @return {number} 865 * @return {number}
840 */ 866 */
841 nestingLevel() { 867 nestingLevel() {
842 return this._nestingLevel; 868 return this._nestingLevel;
843 } 869 }
844 870
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 consoleMessage.type === SDK.ConsoleMessa ge.MessageType.Trace || 914 consoleMessage.type === SDK.ConsoleMessa ge.MessageType.Trace ||
889 consoleMessage.level === SDK.ConsoleMess age.MessageLevel.Warning); 915 consoleMessage.level === SDK.ConsoleMess age.MessageLevel.Warning);
890 if (target && shouldIncludeTrace) 916 if (target && shouldIncludeTrace)
891 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target , this._linkifier); 917 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target , this._linkifier);
892 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table) 918 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table)
893 formattedMessage = this._buildTableMessage(this._message); 919 formattedMessage = this._buildTableMessage(this._message);
894 else 920 else
895 formattedMessage = this._buildMessage(consoleMessage); 921 formattedMessage = this._buildMessage(consoleMessage);
896 contentElement.appendChild(formattedMessage); 922 contentElement.appendChild(formattedMessage);
897 923
898 this.updateTimestamp(Common.moduleSetting('consoleTimestampsEnabled').get()) ; 924 this.updateTimestamp(Common.moduleSetting('consoleTimestampFormat').get());
899 return this._contentElement; 925 return this._contentElement;
900 } 926 }
901 927
902 /** 928 /**
903 * @return {!Element} 929 * @return {!Element}
904 */ 930 */
905 toMessageElement() { 931 toMessageElement() {
906 if (this._element) 932 if (this._element)
907 return this._element; 933 return this._element;
908 934
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 repeatCount() { 1002 repeatCount() {
977 return this._repeatCount || 1; 1003 return this._repeatCount || 1;
978 } 1004 }
979 1005
980 resetIncrementRepeatCount() { 1006 resetIncrementRepeatCount() {
981 this._repeatCount = 1; 1007 this._repeatCount = 1;
982 if (!this._repeatCountElement) 1008 if (!this._repeatCountElement)
983 return; 1009 return;
984 1010
985 this._repeatCountElement.remove(); 1011 this._repeatCountElement.remove();
1012 if (this._contentElement)
1013 this._contentElement.classList.remove('repeated-message');
986 delete this._repeatCountElement; 1014 delete this._repeatCountElement;
987 } 1015 }
988 1016
989 incrementRepeatCount() { 1017 incrementRepeatCount() {
990 this._repeatCount++; 1018 this._repeatCount++;
991 this._showRepeatCountElement(); 1019 this._showRepeatCountElement();
992 } 1020 }
993 1021
994 _showRepeatCountElement() { 1022 _showRepeatCountElement() {
995 if (!this._contentElement) 1023 if (!this._contentElement)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } 1190 }
1163 1191
1164 if (start !== string.length) 1192 if (start !== string.length)
1165 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs tring(start))); 1193 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs tring(start)));
1166 1194
1167 return formattedResult; 1195 return formattedResult;
1168 } 1196 }
1169 }; 1197 };
1170 1198
1171 /** 1199 /**
1200 * @enum {string}
1201 */
1202 Console.ConsoleViewMessage.TimestampFormat = {
1203 None: 'none',
1204 Full: 'full',
1205 Short: 'short'
1206 };
1207
1208 /**
1172 * @unrestricted 1209 * @unrestricted
1173 */ 1210 */
1174 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage { 1211 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage {
1175 /** 1212 /**
1176 * @param {!SDK.ConsoleMessage} consoleMessage 1213 * @param {!SDK.ConsoleMessage} consoleMessage
1177 * @param {!Components.Linkifier} linkifier 1214 * @param {!Components.Linkifier} linkifier
1178 * @param {number} nestingLevel 1215 * @param {number} nestingLevel
1179 */ 1216 */
1180 constructor(consoleMessage, linkifier, nestingLevel) { 1217 constructor(consoleMessage, linkifier, nestingLevel) {
1181 console.assert(consoleMessage.isGroupStartMessage()); 1218 console.assert(consoleMessage.isGroupStartMessage());
(...skipping 26 matching lines...) Expand all
1208 toMessageElement() { 1245 toMessageElement() {
1209 if (!this._element) { 1246 if (!this._element) {
1210 super.toMessageElement(); 1247 super.toMessageElement();
1211 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1248 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1212 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1249 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1213 this.setCollapsed(this._collapsed); 1250 this.setCollapsed(this._collapsed);
1214 } 1251 }
1215 return this._element; 1252 return this._element;
1216 } 1253 }
1217 }; 1254 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698