| OLD | NEW |
| 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 810 |
| 811 /** | 811 /** |
| 812 * @return {boolean} | 812 * @return {boolean} |
| 813 */ | 813 */ |
| 814 matchesFilterRegex(regexObject) { | 814 matchesFilterRegex(regexObject) { |
| 815 regexObject.lastIndex = 0; | 815 regexObject.lastIndex = 0; |
| 816 var text = this.contentElement().deepTextContent(); | 816 var text = this.contentElement().deepTextContent(); |
| 817 return regexObject.test(text); | 817 return regexObject.test(text); |
| 818 } | 818 } |
| 819 | 819 |
| 820 /** | 820 updateTimestamp() { |
| 821 * @param {boolean} show | |
| 822 */ | |
| 823 updateTimestamp(show) { | |
| 824 if (!this._contentElement) | 821 if (!this._contentElement) |
| 825 return; | 822 return; |
| 826 | 823 |
| 827 if (show && !this.timestampElement) { | 824 var format = Common.moduleSetting('consoleTimestampFormat').get(); |
| 828 this.timestampElement = createElementWithClass('span', 'console-timestamp'
); | 825 if (format !== Console.ConsoleViewMessage.TimestampFormat.None) { |
| 829 this.timestampElement.textContent = (new Date(this._message.timestamp)).to
ConsoleTime() + ' '; | 826 var timestampText = formatTimestamp(this._message.timestamp, format); |
| 830 this._contentElement.insertBefore(this.timestampElement, this._contentElem
ent.firstChild); | 827 if (!this._timestampElement) |
| 831 return; | 828 this._timestampElement = createElementWithClass('span', 'console-timesta
mp'); |
| 829 this._timestampElement.textContent = timestampText + ' '; |
| 830 this._timestampElement.title = timestampText; |
| 831 this._contentElement.insertBefore(this._timestampElement, this._contentEle
ment.firstChild); |
| 832 } else if (this._timestampElement) { |
| 833 this._timestampElement.remove(); |
| 834 delete this._timestampElement; |
| 832 } | 835 } |
| 833 | 836 |
| 834 if (!show && this.timestampElement) { | 837 /** |
| 835 this.timestampElement.remove(); | 838 * @param {number} timestamp |
| 836 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 } |
| 837 } | 861 } |
| 838 } | 862 } |
| 839 | 863 |
| 840 /** | 864 /** |
| 841 * @return {number} | 865 * @return {number} |
| 842 */ | 866 */ |
| 843 nestingLevel() { | 867 nestingLevel() { |
| 844 return this._nestingLevel; | 868 return this._nestingLevel; |
| 845 } | 869 } |
| 846 | 870 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 consoleMessage.type === SDK.ConsoleMessa
ge.MessageType.Trace || | 913 consoleMessage.type === SDK.ConsoleMessa
ge.MessageType.Trace || |
| 890 consoleMessage.level === SDK.ConsoleMess
age.MessageLevel.Warning); | 914 consoleMessage.level === SDK.ConsoleMess
age.MessageLevel.Warning); |
| 891 if (target && shouldIncludeTrace) | 915 if (target && shouldIncludeTrace) |
| 892 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target
, this._linkifier); | 916 formattedMessage = this._buildMessageWithStackTrace(consoleMessage, target
, this._linkifier); |
| 893 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table) | 917 else if (this._message.type === SDK.ConsoleMessage.MessageType.Table) |
| 894 formattedMessage = this._buildTableMessage(this._message); | 918 formattedMessage = this._buildTableMessage(this._message); |
| 895 else | 919 else |
| 896 formattedMessage = this._buildMessage(consoleMessage); | 920 formattedMessage = this._buildMessage(consoleMessage); |
| 897 contentElement.appendChild(formattedMessage); | 921 contentElement.appendChild(formattedMessage); |
| 898 | 922 |
| 899 this.updateTimestamp(Common.moduleSetting('consoleTimestampsEnabled').get())
; | 923 this.updateTimestamp(); |
| 900 return this._contentElement; | 924 return this._contentElement; |
| 901 } | 925 } |
| 902 | 926 |
| 903 /** | 927 /** |
| 904 * @return {!Element} | 928 * @return {!Element} |
| 905 */ | 929 */ |
| 906 toMessageElement() { | 930 toMessageElement() { |
| 907 if (this._element) | 931 if (this._element) |
| 908 return this._element; | 932 return this._element; |
| 909 | 933 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 repeatCount() { | 1004 repeatCount() { |
| 981 return this._repeatCount || 1; | 1005 return this._repeatCount || 1; |
| 982 } | 1006 } |
| 983 | 1007 |
| 984 resetIncrementRepeatCount() { | 1008 resetIncrementRepeatCount() { |
| 985 this._repeatCount = 1; | 1009 this._repeatCount = 1; |
| 986 if (!this._repeatCountElement) | 1010 if (!this._repeatCountElement) |
| 987 return; | 1011 return; |
| 988 | 1012 |
| 989 this._repeatCountElement.remove(); | 1013 this._repeatCountElement.remove(); |
| 1014 if (this._contentElement) |
| 1015 this._contentElement.classList.remove('repeated-message'); |
| 990 delete this._repeatCountElement; | 1016 delete this._repeatCountElement; |
| 991 } | 1017 } |
| 992 | 1018 |
| 993 incrementRepeatCount() { | 1019 incrementRepeatCount() { |
| 994 this._repeatCount++; | 1020 this._repeatCount++; |
| 995 this._showRepeatCountElement(); | 1021 this._showRepeatCountElement(); |
| 996 } | 1022 } |
| 997 | 1023 |
| 998 _showRepeatCountElement() { | 1024 _showRepeatCountElement() { |
| 999 if (!this._contentElement) | 1025 if (!this._contentElement) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 } | 1192 } |
| 1167 | 1193 |
| 1168 if (start !== string.length) | 1194 if (start !== string.length) |
| 1169 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs
tring(start))); | 1195 formattedResult.appendChild(Components.linkifyStringAsFragment(string.subs
tring(start))); |
| 1170 | 1196 |
| 1171 return formattedResult; | 1197 return formattedResult; |
| 1172 } | 1198 } |
| 1173 }; | 1199 }; |
| 1174 | 1200 |
| 1175 /** | 1201 /** |
| 1202 * @enum {string} |
| 1203 */ |
| 1204 Console.ConsoleViewMessage.TimestampFormat = { |
| 1205 None: 'none', |
| 1206 Full: 'full', |
| 1207 Short: 'short' |
| 1208 }; |
| 1209 |
| 1210 /** |
| 1176 * @unrestricted | 1211 * @unrestricted |
| 1177 */ | 1212 */ |
| 1178 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage { | 1213 Console.ConsoleGroupViewMessage = class extends Console.ConsoleViewMessage { |
| 1179 /** | 1214 /** |
| 1180 * @param {!SDK.ConsoleMessage} consoleMessage | 1215 * @param {!SDK.ConsoleMessage} consoleMessage |
| 1181 * @param {!Components.Linkifier} linkifier | 1216 * @param {!Components.Linkifier} linkifier |
| 1182 * @param {number} nestingLevel | 1217 * @param {number} nestingLevel |
| 1183 */ | 1218 */ |
| 1184 constructor(consoleMessage, linkifier, nestingLevel) { | 1219 constructor(consoleMessage, linkifier, nestingLevel) { |
| 1185 console.assert(consoleMessage.isGroupStartMessage()); | 1220 console.assert(consoleMessage.isGroupStartMessage()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1212 toMessageElement() { | 1247 toMessageElement() { |
| 1213 if (!this._element) { | 1248 if (!this._element) { |
| 1214 super.toMessageElement(); | 1249 super.toMessageElement(); |
| 1215 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); | 1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); |
| 1216 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem
ent.firstChild); | 1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem
ent.firstChild); |
| 1217 this.setCollapsed(this._collapsed); | 1252 this.setCollapsed(this._collapsed); |
| 1218 } | 1253 } |
| 1219 return this._element; | 1254 return this._element; |
| 1220 } | 1255 } |
| 1221 }; | 1256 }; |
| OLD | NEW |