Chromium Code Reviews| 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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 | 837 |
| 838 /** | 838 /** |
| 839 * @return {boolean} | 839 * @return {boolean} |
| 840 */ | 840 */ |
| 841 matchesRegex: function(regexObject) | 841 matchesRegex: function(regexObject) |
| 842 { | 842 { |
| 843 regexObject.lastIndex = 0; | 843 regexObject.lastIndex = 0; |
| 844 return regexObject.test(this._formattedMessageText()) || (!!this._anchor Element && regexObject.test(this._anchorElement.textContent)); | 844 return regexObject.test(this._formattedMessageText()) || (!!this._anchor Element && regexObject.test(this._anchorElement.textContent)); |
| 845 }, | 845 }, |
| 846 | 846 |
| 847 _updateTimestamp: function() | |
| 848 { | |
| 849 if (!this.timestampElement) | |
|
apavlov
2014/03/06 09:56:20
I suspect it should always be present (see below).
| |
| 850 return; | |
| 851 | |
| 852 var date = new Date(this._message.timestamp * 1000); | |
|
apavlov
2014/03/06 09:56:20
This is the only client of ConsoleMessage.timestam
| |
| 853 var str = date.getFullYear() + "-" | |
| 854 + ("0" + (date.getMonth() + 1)).slice(-2) + "-" | |
|
apavlov
2014/03/06 09:56:20
This slicing is relatively slow, and I suspect it
| |
| 855 + ("0" + date.getDate()).slice(-2) + " " | |
| 856 + ("0" + date.getHours()).slice(-2) + ":" | |
| 857 + ("0" + date.getMinutes()).slice(-2) + ":" | |
| 858 + ("0" + date.getSeconds()).slice(-2) + "." | |
| 859 + date.getMilliseconds(); | |
|
eustas
2014/03/06 15:40:05
Milliseconds should be padded.
| |
| 860 | |
| 861 this.timestampElement.textContent = str; | |
| 862 }, | |
| 863 | |
| 847 /** | 864 /** |
| 848 * @return {!Element} | 865 * @return {!Element} |
| 849 */ | 866 */ |
| 850 toMessageElement: function() | 867 toMessageElement: function() |
| 851 { | 868 { |
| 852 if (this._element) | 869 if (this._element) |
| 853 return this._element; | 870 return this._element; |
| 854 | 871 |
| 855 var element = document.createElement("div"); | 872 var element = document.createElement("div"); |
| 856 element.message = this; | 873 element.message = this; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 872 element.classList.add("console-error-level"); | 889 element.classList.add("console-error-level"); |
| 873 break; | 890 break; |
| 874 case WebInspector.ConsoleMessage.MessageLevel.Info: | 891 case WebInspector.ConsoleMessage.MessageLevel.Info: |
| 875 element.classList.add("console-info-level"); | 892 element.classList.add("console-info-level"); |
| 876 break; | 893 break; |
| 877 } | 894 } |
| 878 | 895 |
| 879 if (this._message.type === WebInspector.ConsoleMessage.MessageType.Start Group || this._message.type === WebInspector.ConsoleMessage.MessageType.StartGro upCollapsed) | 896 if (this._message.type === WebInspector.ConsoleMessage.MessageType.Start Group || this._message.type === WebInspector.ConsoleMessage.MessageType.StartGro upCollapsed) |
| 880 element.classList.add("console-group-title"); | 897 element.classList.add("console-group-title"); |
| 881 | 898 |
| 899 if (WebInspector.settings.consoleTimestampsEnabled.get()) { | |
|
apavlov
2014/03/06 09:56:20
We should also think of a way to add/remove the ti
| |
| 900 this.timestampElement = document.createElement("span"); | |
|
apavlov
2014/03/06 09:56:20
This snippet can be written as:
this.timestampEle
| |
| 901 this.timestampElement.className = "console-timestamp"; | |
| 902 this._updateTimestamp(); | |
| 903 | |
| 904 element.appendChild(this.timestampElement); | |
| 905 } | |
| 906 | |
| 882 element.appendChild(this.formattedMessage()); | 907 element.appendChild(this.formattedMessage()); |
| 883 | 908 |
| 884 if (this._message.repeatCount > 1) | 909 if (this._message.repeatCount > 1) |
| 885 this.updateRepeatCount(); | 910 this.updateRepeatCount(); |
| 886 | 911 |
| 887 return element; | 912 return element; |
| 888 }, | 913 }, |
| 889 | 914 |
| 890 _populateStackTraceTreeElement: function(parentTreeElement) | 915 _populateStackTraceTreeElement: function(parentTreeElement) |
| 891 { | 916 { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 917 return; | 942 return; |
| 918 | 943 |
| 919 if (!this.repeatCountElement) { | 944 if (!this.repeatCountElement) { |
| 920 this.repeatCountElement = document.createElement("span"); | 945 this.repeatCountElement = document.createElement("span"); |
| 921 this.repeatCountElement.className = "bubble"; | 946 this.repeatCountElement.className = "bubble"; |
| 922 | 947 |
| 923 this._element.insertBefore(this.repeatCountElement, this._element.fi rstChild); | 948 this._element.insertBefore(this.repeatCountElement, this._element.fi rstChild); |
| 924 this._element.classList.add("repeated-message"); | 949 this._element.classList.add("repeated-message"); |
| 925 } | 950 } |
| 926 this.repeatCountElement.textContent = this._message.repeatCount; | 951 this.repeatCountElement.textContent = this._message.repeatCount; |
| 952 this._updateTimestamp(); | |
| 927 }, | 953 }, |
| 928 | 954 |
| 929 /** | 955 /** |
| 930 * @return {string} | 956 * @return {string} |
| 931 */ | 957 */ |
| 932 toString: function() | 958 toString: function() |
| 933 { | 959 { |
| 934 var sourceString; | 960 var sourceString; |
| 935 switch (this._message.source) { | 961 switch (this._message.source) { |
| 936 case WebInspector.ConsoleMessage.MessageSource.XML: | 962 case WebInspector.ConsoleMessage.MessageSource.XML: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 } | 1044 } |
| 1019 | 1045 |
| 1020 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; | 1046 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; |
| 1021 }, | 1047 }, |
| 1022 | 1048 |
| 1023 get text() | 1049 get text() |
| 1024 { | 1050 { |
| 1025 return this._message.messageText; | 1051 return this._message.messageText; |
| 1026 } | 1052 } |
| 1027 } | 1053 } |
| OLD | NEW |