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

Side by Side Diff: Source/devtools/front_end/ConsoleModel.js

Issue 185713007: DevTools: Add timestamp support in the console (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make repeat count work 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 * @param {?string} level 162 * @param {?string} level
163 * @param {string} text 163 * @param {string} text
164 * @param {string=} type 164 * @param {string=} type
165 * @param {?string=} url 165 * @param {?string=} url
166 * @param {number=} line 166 * @param {number=} line
167 * @param {number=} column 167 * @param {number=} column
168 * @param {number=} repeatCount 168 * @param {number=} repeatCount
169 * @param {!NetworkAgent.RequestId=} requestId 169 * @param {!NetworkAgent.RequestId=} requestId
170 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters 170 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
171 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace 171 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace
172 * @param {number=} timestamp
172 * @param {boolean=} isOutdated 173 * @param {boolean=} isOutdated
173 */ 174 */
174 WebInspector.ConsoleMessage = function(source, level, text, type, url, line, col umn, repeatCount, requestId, parameters, stackTrace, isOutdated) 175 WebInspector.ConsoleMessage = function(source, level, text, type, url, line, col umn, repeatCount, requestId, parameters, stackTrace, timestamp, isOutdated)
175 { 176 {
176 this.source = source; 177 this.source = source;
177 this.level = level; 178 this.level = level;
178 this.messageText = text; 179 this.messageText = text;
179 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; 180 this.type = type || WebInspector.ConsoleMessage.MessageType.Log;
180 this.url = url || null; 181 this.url = url || null;
181 this.line = line || 0; 182 this.line = line || 0;
182 this.column = column || 0; 183 this.column = column || 0;
183 this.parameters = parameters; 184 this.parameters = parameters;
184 this.stackTrace = stackTrace; 185 this.stackTrace = stackTrace;
186 this.timestamp = timestamp || Date.now() / 1000;
185 this.isOutdated = isOutdated; 187 this.isOutdated = isOutdated;
186 188
187 repeatCount = repeatCount || 1; 189 repeatCount = repeatCount || 1;
188 this.repeatCount = repeatCount; 190 this.repeatCount = repeatCount;
189 this.repeatDelta = repeatCount; 191 this.repeatDelta = repeatCount;
190 this.totalRepeatCount = repeatCount; 192 this.totalRepeatCount = repeatCount;
191 this.request = requestId ? WebInspector.networkLog.requestForId(requestId) : null; 193 this.request = requestId ? WebInspector.networkLog.requestForId(requestId) : null;
192 } 194 }
193 195
194 WebInspector.ConsoleMessage.prototype = { 196 WebInspector.ConsoleMessage.prototype = {
195 /** 197 /**
196 * @return {boolean} 198 * @return {boolean}
197 */ 199 */
198 isErrorOrWarning: function() 200 isErrorOrWarning: function()
199 { 201 {
200 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error); 202 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error);
201 }, 203 },
202 204
203 /** 205 /**
204 * @return {!WebInspector.ConsoleMessage} 206 * @return {!WebInspector.ConsoleMessage}
205 */ 207 */
206 clone: function() 208 clone: function()
207 { 209 {
208 return new WebInspector.ConsoleMessage(this.source, this.level, this.tex t, this.type, this.url, this.line, this.column, this.repeatCount, this.requestId , this.parameters, this.stackTrace, this.isOutdated); 210 return new WebInspector.ConsoleMessage(this.source, this.level, this.tex t, this.type, this.url, this.line, this.column, this.repeatCount, this.requestId , this.parameters, this.stackTrace, this.timestamp, this.isOutdated);
209 }, 211 },
210 212
211 /** 213 /**
212 * @param {?WebInspector.ConsoleMessage} msg 214 * @param {?WebInspector.ConsoleMessage} msg
213 * @return {boolean} 215 * @return {boolean}
214 */ 216 */
215 isEqual: function(msg) 217 isEqual: function(msg)
216 { 218 {
217 if (!msg) 219 if (!msg)
218 return false; 220 return false;
219 221
220 if (this.stackTrace) { 222 if (this.stackTrace) {
221 if (!msg.stackTrace) 223 if (!msg.stackTrace)
222 return false; 224 return false;
223 var l = this.stackTrace; 225 var l = this.stackTrace;
224 var r = msg.stackTrace; 226 var r = msg.stackTrace;
225 if (l.length !== r.length) 227 if (l.length !== r.length)
226 return false; 228 return false;
227 for (var i = 0; i < l.length; i++) { 229 for (var i = 0; i < l.length; i++) {
228 if (l[i].url !== r[i].url || 230 if (l[i].url !== r[i].url ||
229 l[i].functionName !== r[i].functionName || 231 l[i].functionName !== r[i].functionName ||
230 l[i].lineNumber !== r[i].lineNumber || 232 l[i].lineNumber !== r[i].lineNumber ||
231 l[i].columnNumber !== r[i].columnNumber) 233 l[i].columnNumber !== r[i].columnNumber)
232 return false; 234 return false;
233 } 235 }
234 } 236 }
235 237
238 // Timestamp doesn't affect equality.
236 return (this.source === msg.source) 239 return (this.source === msg.source)
237 && (this.type === msg.type) 240 && (this.type === msg.type)
238 && (this.level === msg.level) 241 && (this.level === msg.level)
239 && (this.line === msg.line) 242 && (this.line === msg.line)
240 && (this.url === msg.url) 243 && (this.url === msg.url)
241 && (this.messageText === msg.messageText) 244 && (this.messageText === msg.messageText)
242 && (this.request === msg.request); 245 && (this.request === msg.request);
243 } 246 }
244 } 247 }
245 248
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 payload.level, 307 payload.level,
305 payload.text, 308 payload.text,
306 payload.type, 309 payload.type,
307 payload.url, 310 payload.url,
308 payload.line, 311 payload.line,
309 payload.column, 312 payload.column,
310 payload.repeatCount, 313 payload.repeatCount,
311 payload.networkRequestId, 314 payload.networkRequestId,
312 payload.parameters, 315 payload.parameters,
313 payload.stackTrace, 316 payload.stackTrace,
317 payload.timestamp,
314 this._console._enablingConsole); 318 this._console._enablingConsole);
315 this._console.addMessage(consoleMessage, true); 319 this._console.addMessage(consoleMessage, true);
316 }, 320 },
317 321
318 /** 322 /**
319 * @param {number} count 323 * @param {number} count
320 */ 324 */
321 messageRepeatCountUpdated: function(count) 325 messageRepeatCountUpdated: function(count)
322 { 326 {
323 this._console._messageRepeatCountUpdated(count); 327 this._console._messageRepeatCountUpdated(count);
324 }, 328 },
325 329
326 messagesCleared: function() 330 messagesCleared: function()
327 { 331 {
328 if (!WebInspector.settings.preserveConsoleLog.get()) 332 if (!WebInspector.settings.preserveConsoleLog.get())
329 this._console.clearMessages(); 333 this._console.clearMessages();
330 } 334 }
331 } 335 }
332 336
333 /** 337 /**
334 * @type {!WebInspector.ConsoleModel} 338 * @type {!WebInspector.ConsoleModel}
335 */ 339 */
336 WebInspector.console; 340 WebInspector.console;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698