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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/ConsoleView.js ('k') | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 this._dataGrids = []; 45 this._dataGrids = [];
46 /** @type {!Map.<!WebInspector.DataGrid, ?Element>} */ 46 /** @type {!Map.<!WebInspector.DataGrid, ?Element>} */
47 this._dataGridParents = new Map(); 47 this._dataGridParents = new Map();
48 48
49 this._customFormatters = { 49 this._customFormatters = {
50 "object": this._formatParameterAsObject, 50 "object": this._formatParameterAsObject,
51 "array": this._formatParameterAsArray, 51 "array": this._formatParameterAsArray,
52 "node": this._formatParameterAsNode, 52 "node": this._formatParameterAsNode,
53 "string": this._formatParameterAsString 53 "string": this._formatParameterAsString
54 }; 54 };
55
56 WebInspector.settings.consoleTimestampsEnabled.addChangeListener(this._conso leTimestampsSettingChanged, this);
55 } 57 }
56 58
57 WebInspector.ConsoleViewMessage.prototype = { 59 WebInspector.ConsoleViewMessage.prototype = {
58 wasShown: function() 60 wasShown: function()
59 { 61 {
60 for (var i = 0; this._dataGrids && i < this._dataGrids.length; ++i) { 62 for (var i = 0; this._dataGrids && i < this._dataGrids.length; ++i) {
61 var dataGrid = this._dataGrids[i]; 63 var dataGrid = this._dataGrids[i];
62 var parentElement = this._dataGridParents.get(dataGrid) || null; 64 var parentElement = this._dataGridParents.get(dataGrid) || null;
63 dataGrid.show(parentElement); 65 dataGrid.show(parentElement);
64 dataGrid.updateWidths(); 66 dataGrid.updateWidths();
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 840
839 /** 841 /**
840 * @return {boolean} 842 * @return {boolean}
841 */ 843 */
842 matchesRegex: function(regexObject) 844 matchesRegex: function(regexObject)
843 { 845 {
844 regexObject.lastIndex = 0; 846 regexObject.lastIndex = 0;
845 return regexObject.test(this._formattedMessageText()) || (!!this._anchor Element && regexObject.test(this._anchorElement.textContent)); 847 return regexObject.test(this._formattedMessageText()) || (!!this._anchor Element && regexObject.test(this._anchorElement.textContent));
846 }, 848 },
847 849
850 _updateTimestamp: function(show)
851 {
852 if (!this._element)
853 return;
854
855 if (show && !this.timestampElement) {
856 this.timestampElement = this._element.createChild("span", "console-t imestamp");
857 this.timestampElement.textContent = (new Date(this._message.timestam p)).toConsoleTime();
858 var afterRepeatCountChild = this.repeatCountElement && this.repeatCo untElement.nextSibling;
859 this._element.insertBefore(this.timestampElement, afterRepeatCountCh ild || this._element.firstChild);
860 return;
861 }
862
863 if (!show && this.timestampElement)
864 this.timestampElement.remove();
865 },
866
867 _consoleTimestampsSettingChanged: function(event)
868 {
869 var enabled = /** @type {boolean} */ (event.data);
870 this._updateTimestamp(enabled);
871 },
872
848 /** 873 /**
849 * @return {!Element} 874 * @return {!Element}
850 */ 875 */
851 toMessageElement: function() 876 toMessageElement: function()
852 { 877 {
853 if (this._element) 878 if (this._element)
854 return this._element; 879 return this._element;
855 880
856 var element = document.createElement("div"); 881 var element = document.createElement("div");
857 element.message = this; 882 element.message = this;
(...skipping 20 matching lines...) Expand all
878 } 903 }
879 904
880 if (this._message.type === WebInspector.ConsoleMessage.MessageType.Start Group || this._message.type === WebInspector.ConsoleMessage.MessageType.StartGro upCollapsed) 905 if (this._message.type === WebInspector.ConsoleMessage.MessageType.Start Group || this._message.type === WebInspector.ConsoleMessage.MessageType.StartGro upCollapsed)
881 element.classList.add("console-group-title"); 906 element.classList.add("console-group-title");
882 907
883 element.appendChild(this.formattedMessage()); 908 element.appendChild(this.formattedMessage());
884 909
885 if (this._repeatCount > 1) 910 if (this._repeatCount > 1)
886 this._showRepeatCountElement(); 911 this._showRepeatCountElement();
887 912
913 this._updateTimestamp(WebInspector.settings.consoleTimestampsEnabled.get ());
914
888 return element; 915 return element;
889 }, 916 },
890 917
891 _populateStackTraceTreeElement: function(parentTreeElement) 918 _populateStackTraceTreeElement: function(parentTreeElement)
892 { 919 {
893 for (var i = 0; i < this._message.stackTrace.length; i++) { 920 for (var i = 0; i < this._message.stackTrace.length; i++) {
894 var frame = this._message.stackTrace[i]; 921 var frame = this._message.stackTrace[i];
895 922
896 var content = document.createElementWithClass("div", "stacktrace-ent ry"); 923 var content = document.createElementWithClass("div", "stacktrace-ent ry");
897 var messageTextElement = document.createElement("span"); 924 var messageTextElement = document.createElement("span");
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 } 1053 }
1027 1054
1028 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; 1055 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line;
1029 }, 1056 },
1030 1057
1031 get text() 1058 get text()
1032 { 1059 {
1033 return this._message.messageText; 1060 return this._message.messageText;
1034 } 1061 }
1035 } 1062 }
OLDNEW
« 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