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

Side by Side Diff: remoting/webapp/me2mom/debug_log.js

Issue 8336004: Improve web-app type safety. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Module to support logging debug messages. 7 * Module to support logging debug messages.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 (function() { 15 /**
16 16 * @constructor
17 /** @constructor */ 17 * @param {Element} logElement The HTML div to which to add log messages.
18 */
18 remoting.DebugLog = function(logElement) { 19 remoting.DebugLog = function(logElement) {
19 this.debugLog = logElement; 20 this.debugLog = logElement;
20 } 21 };
21 22
22 // Maximum numer of lines to record in the debug log. 23 /** Maximum numer of lines to record in the debug log. Only the most
simonmorris 2011/10/18 00:55:36 "numer" -> "number"
Jamie 2011/10/18 01:42:01 Done.
23 // Only the most recent <n> lines are displayed. 24 * recent <n> lines are displayed. */
24 var MAX_DEBUG_LOG_SIZE = 1000; 25 remoting.DebugLog.prototype.MAX_DEBUG_LOG_SIZE = 1000;
Jamie 2011/10/18 00:19:27 Getting rid of the scoping function would push thi
25 26
26 /** 27 /**
27 * Add the given message to the debug log. 28 * Add the given message to the debug log.
28 * 29 *
29 * @param {string} message The debug info to add to the log. 30 * @param {string} message The debug info to add to the log.
30 */ 31 */
31 remoting.DebugLog.prototype.log = function(message) { 32 remoting.DebugLog.prototype.log = function(message) {
32 // Remove lines from top if we've hit our max log size. 33 // Remove lines from top if we've hit our max log size.
33 if (this.debugLog.childNodes.length == MAX_DEBUG_LOG_SIZE) { 34 if (this.debugLog.childNodes.length == this.MAX_DEBUG_LOG_SIZE) {
34 this.debugLog.removeChild(this.debugLog.firstChild); 35 this.debugLog.removeChild(this.debugLog.firstChild);
35 } 36 }
36 37
37 // Add the new <p> to the end of the debug log. 38 // Add the new <p> to the end of the debug log.
38 var p = document.createElement('p'); 39 var p = document.createElement('p');
39 p.appendChild(document.createTextNode(message)); 40 p.appendChild(document.createTextNode(message));
40 this.debugLog.appendChild(p); 41 this.debugLog.appendChild(p);
41 42
42 // Scroll to bottom of div 43 // Scroll to bottom of div
43 this.debugLog.scrollTop = this.debugLog.scrollHeight; 44 this.debugLog.scrollTop = this.debugLog.scrollHeight;
44 } 45 };
45 46
46 }()); 47 /** @type {remoting.DebugLog} */
48 remoting.debug = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698