OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Base class for classes that can log their behavior. |
| 7 */ |
| 8 |
| 9 goog.provide('cvox.AbstractLogger'); |
| 10 |
| 11 /** |
| 12 * Creates a new instance. |
| 13 * @constructor |
| 14 */ |
| 15 cvox.AbstractLogger = function() { |
| 16 if (this.logEnabled()) { |
| 17 this.debuglog = new Array(); |
| 18 } |
| 19 }; |
| 20 |
| 21 /** |
| 22 * @return {string} The human-readable name of this instance. |
| 23 */ |
| 24 cvox.AbstractLogger.prototype.getName = function() { |
| 25 return 'AbstractLogger'; |
| 26 }; |
| 27 |
| 28 /** |
| 29 * @return {boolean} If logging is enabled. |
| 30 */ |
| 31 cvox.AbstractLogger.prototype.logEnabled = function() { |
| 32 return true; |
| 33 }; |
| 34 |
| 35 /** |
| 36 * Debugging function - adds the string to the log of utterances. |
| 37 * @param {string} msgString The string of text to log. |
| 38 */ |
| 39 cvox.AbstractLogger.prototype.log = function(msgString) { |
| 40 if (!this.logEnabled()) { |
| 41 return; |
| 42 } |
| 43 this.debuglog.push(msgString); |
| 44 if (console) { |
| 45 console.log(msgString); |
| 46 } |
| 47 }; |
| 48 |
| 49 /** |
| 50 * Debugging function - returns the log of utterances. |
| 51 * @return {Array} The log of utterances. |
| 52 */ |
| 53 cvox.AbstractLogger.prototype.getLog = function() { |
| 54 return this.debuglog; |
| 55 }; |
| 56 |
| 57 /** |
| 58 * Debugging function - resets the log of utterances. |
| 59 */ |
| 60 cvox.AbstractLogger.prototype.resetLog = function() { |
| 61 this.debuglog = new Array(); |
| 62 }; |
OLD | NEW |