Skip to content
Browse files

Adds log console setter.

R=nnaze
DELTA=23 (22 added, 0 deleted, 1 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6065


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2410 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent 8b8389d commit da2ae1b83f0ce1cf4c8e51581a697c4f362e10c3 haibinlu@google.com committed Jan 3, 2013
Showing with 23 additions and 1 deletion.
  1. +10 −1 closure/goog/debug/console.js
  2. +13 −0 closure/goog/debug/console_test.html
View
11 closure/goog/debug/console.js
@@ -151,14 +151,23 @@ goog.debug.Console.instance = null;
/**
* The console to which to log. This is a property so it can be mocked out in
- * unit testing.
+ * this unit test for goog.debug.Console.
* @type {Object}
* @private
*/
goog.debug.Console.console_ = window.console;
/**
+ * Sets the console to which to log.
+ * @param {!Object} console The console to which to log.
+ */
+goog.debug.Console.setConsole = function(console) {
+ goog.debug.Console.console_ = console;
+};
+
+
+/**
* Install the console and start capturing if "Debug=true" is in the page URL
*/
goog.debug.Console.autoInstall = function() {
View
13 closure/goog/debug/console_test.html
@@ -149,6 +149,19 @@
assertEquals(3, mockConsole.log.getCallCount());
}
+function testSetConsole() {
+ var fakeConsole = {log: goog.testing.recordFunction()};
+
+ logAtLevel(goog.debug.Logger.Level.INFO, 'test message 1');
+ logAtAllLevels('test message 1');
+ assertEquals(0, fakeConsole.log.getCallCount());
+
+ goog.debug.Console.setConsole(fakeConsole);
+
+ logAtLevel(goog.debug.Logger.Level.INFO, 'test message 2');
+ assertEquals(1, fakeConsole.log.getCallCount());
+}
+
/**
* Logs the message at all log levels.

0 comments on commit da2ae1b

Please sign in to comment.
Something went wrong with that request. Please try again.