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

Side by Side Diff: Source/devtools/front_end/console/ConsoleView.js

Issue 298333003: DevTools: Implement console message logging through an extension (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove duplicate logging Created 6 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 this._prompt.renderAsBlock(); 131 this._prompt.renderAsBlock();
132 this._prompt.attach(this._promptElement); 132 this._prompt.attach(this._promptElement);
133 this._prompt.proxyElement.addEventListener("keydown", this._promptKeyDown.bi nd(this), false); 133 this._prompt.proxyElement.addEventListener("keydown", this._promptKeyDown.bi nd(this), false);
134 this._prompt.setHistoryData(WebInspector.settings.consoleHistory.get()); 134 this._prompt.setHistoryData(WebInspector.settings.consoleHistory.get());
135 var historyData = WebInspector.settings.consoleHistory.get(); 135 var historyData = WebInspector.settings.consoleHistory.get();
136 this._prompt.setHistoryData(historyData); 136 this._prompt.setHistoryData(historyData);
137 137
138 this._updateFilterStatus(); 138 this._updateFilterStatus();
139 WebInspector.settings.consoleTimestampsEnabled.addChangeListener(this._conso leTimestampsSettingChanged, this); 139 WebInspector.settings.consoleTimestampsEnabled.addChangeListener(this._conso leTimestampsSettingChanged, this);
140 140
141 this._registerWithMessageSink();
141 WebInspector.targetManager.observeTargets(this); 142 WebInspector.targetManager.observeTargets(this);
142 } 143 }
143 144
144 WebInspector.ConsoleView.prototype = { 145 WebInspector.ConsoleView.prototype = {
145 /** 146 /**
146 * @return {number} 147 * @return {number}
147 */ 148 */
148 itemCount: function() 149 itemCount: function()
149 { 150 {
150 return this._visibleViewMessages.length; 151 return this._visibleViewMessages.length;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 */ 191 */
191 targetRemoved: function(target) 192 targetRemoved: function(target)
192 { 193 {
193 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events .MessageAdded, this._onConsoleMessageAdded, this); 194 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events .MessageAdded, this._onConsoleMessageAdded, this);
194 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events .ConsoleCleared, this._consoleCleared, this); 195 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events .ConsoleCleared, this._consoleCleared, this);
195 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events .CommandEvaluated, this._commandEvaluated, this); 196 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events .CommandEvaluated, this._commandEvaluated, this);
196 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events .ExecutionContextCreated, this._onExecutionContextCreated, this); 197 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events .ExecutionContextCreated, this._onExecutionContextCreated, this);
197 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events .ExecutionContextDestroyed, this._onExecutionContextDestroyed, this); 198 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events .ExecutionContextDestroyed, this._onExecutionContextDestroyed, this);
198 }, 199 },
199 200
201 _registerWithMessageSink: function()
202 {
203 WebInspector.messageSink.messages().forEach(this._addSinkMessage, this);
204 WebInspector.messageSink.addEventListener(WebInspector.MessageSink.Event s.MessageAdded, messageAdded, this);
205
206 /**
207 * @param {!WebInspector.Event} event
208 * @this {WebInspector.ConsoleView}
209 */
210 function messageAdded(event)
211 {
212 this._addSinkMessage(/** @type {!WebInspector.MessageSink.Message} * / (event.data));
213 }
214 },
215
216 /**
217 * @param {!WebInspector.MessageSink.Message} message
218 */
219 _addSinkMessage: function(message)
220 {
221 var level = WebInspector.ConsoleMessage.MessageLevel.Debug;
222 switch (message.level) {
223 case WebInspector.MessageSink.MessageLevel.Error:
224 level = WebInspector.ConsoleMessage.MessageLevel.Error;
225 break;
226 case WebInspector.MessageSink.MessageLevel.Warning:
227 level = WebInspector.ConsoleMessage.MessageLevel.Warning;
228 break;
229 }
230
231 var consoleMessage = new WebInspector.ConsoleMessage(null, WebInspector. ConsoleMessage.MessageSource.Other, level, message.text,
232 undefined, undefined, undefined, undefined, undefined, undefined , undefined, message.timestamp);
233 this._addConsoleMessage(consoleMessage);
234 },
235
200 /** 236 /**
201 * @param {!WebInspector.Event} event 237 * @param {!WebInspector.Event} event
202 */ 238 */
203 _consoleTimestampsSettingChanged: function(event) 239 _consoleTimestampsSettingChanged: function(event)
204 { 240 {
205 var enabled = /** @type {boolean} */ (event.data); 241 var enabled = /** @type {boolean} */ (event.data);
206 this._updateMessageList(); 242 this._updateMessageList();
207 this._consoleMessages.forEach(function(viewMessage) { 243 this._consoleMessages.forEach(function(viewMessage) {
208 viewMessage.updateTimestamp(enabled); 244 viewMessage.updateTimestamp(enabled);
209 }); 245 });
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 this._updateFilterStatus(); 454 this._updateFilterStatus();
419 } 455 }
420 }, 456 },
421 457
422 /** 458 /**
423 * @param {!WebInspector.Event} event 459 * @param {!WebInspector.Event} event
424 */ 460 */
425 _onConsoleMessageAdded: function(event) 461 _onConsoleMessageAdded: function(event)
426 { 462 {
427 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data); 463 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data);
464 this._addConsoleMessage(message);
465 },
466
467 /**
468 * @param {!WebInspector.ConsoleMessage} message
469 */
470 _addConsoleMessage: function(message)
471 {
428 var viewMessage = this._createViewMessage(message); 472 var viewMessage = this._createViewMessage(message);
429 this._consoleMessageAdded(viewMessage); 473 this._consoleMessageAdded(viewMessage);
430 this._scheduleViewportRefresh(); 474 this._scheduleViewportRefresh();
431 }, 475 },
432 476
433 /** 477 /**
434 * @param {!WebInspector.ConsoleViewMessage} viewMessage 478 * @param {!WebInspector.ConsoleViewMessage} viewMessage
435 */ 479 */
436 _showConsoleMessage: function(viewMessage) 480 _showConsoleMessage: function(viewMessage)
437 { 481 {
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 }, 963 },
920 964
921 /** 965 /**
922 * @param {!WebInspector.ConsoleViewMessage} viewMessage 966 * @param {!WebInspector.ConsoleViewMessage} viewMessage
923 * @return {boolean} 967 * @return {boolean}
924 */ 968 */
925 shouldBeVisible: function(viewMessage) 969 shouldBeVisible: function(viewMessage)
926 { 970 {
927 var message = viewMessage.consoleMessage(); 971 var message = viewMessage.consoleMessage();
928 var executionContext = WebInspector.context.flavor(WebInspector.Executio nContext); 972 var executionContext = WebInspector.context.flavor(WebInspector.Executio nContext);
973 if (!message.target())
974 return true;
975
929 if (!this._view._showAllMessagesCheckbox.checked() && executionContext & & (message.target() !== executionContext.target() || message.executionContextId !== executionContext.id)) 976 if (!this._view._showAllMessagesCheckbox.checked() && executionContext & & (message.target() !== executionContext.target() || message.executionContextId !== executionContext.id))
930 return false; 977 return false;
931 978
932 if (viewMessage.consoleMessage().isGroupMessage()) 979 if (viewMessage.consoleMessage().isGroupMessage())
933 return true; 980 return true;
934 981
935 if (message.type === WebInspector.ConsoleMessage.MessageType.Result || m essage.type === WebInspector.ConsoleMessage.MessageType.Command) 982 if (message.type === WebInspector.ConsoleMessage.MessageType.Result || m essage.type === WebInspector.ConsoleMessage.MessageType.Command)
936 return true; 983 return true;
937 984
938 if (message.url && this._messageURLFilters[message.url]) 985 if (message.url && this._messageURLFilters[message.url])
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = { 1176 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = {
1130 /** 1177 /**
1131 * @return {boolean} 1178 * @return {boolean}
1132 */ 1179 */
1133 handleAction: function() 1180 handleAction: function()
1134 { 1181 {
1135 WebInspector.console.show(); 1182 WebInspector.console.show();
1136 return true; 1183 return true;
1137 } 1184 }
1138 } 1185 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/common/Settings.js ('k') | Source/devtools/front_end/console/ConsoleViewMessage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698