[Pkg-javascript-commits] [less.js] 154/285: Fix tests by adding logger to record messages in test common js
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit 9be165ba8a6b5e7e0ad1bd520f60f978da53aeac
Author: Luke Page <luke.a.page at gmail.com>
Date: Tue Oct 7 07:42:35 2014 +0100
Fix tests by adding logger to record messages in test common js
---
lib/less-browser/index.js | 47 ++++++++++++++++++++++++++---------------------
lib/less/logger.js | 2 +-
test/browser/common.js | 17 +++++++++--------
3 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/lib/less-browser/index.js b/lib/less-browser/index.js
index e75f067..86e5ec9 100644
--- a/lib/less-browser/index.js
+++ b/lib/less-browser/index.js
@@ -28,28 +28,33 @@ var logLevel = {
errors: 1,
none: 0
};
-less.logger.addListener({
- debug: function(msg) {
- if (options.logLevel >= logLevel.debug) {
- console.log(msg);
- }
- },
- info: function(msg) {
- if (options.logLevel >= logLevel.info) {
- console.log(msg);
- }
- },
- warn: function(msg) {
- if (options.logLevel >= logLevel.warn) {
- console.warn(msg);
- }
- },
- error: function(msg) {
- if (options.logLevel >= logLevel.error) {
- console.error(msg);
+if (!options.loggers) {
+ options.loggers = [{
+ debug: function(msg) {
+ if (options.logLevel >= logLevel.debug) {
+ console.log(msg);
+ }
+ },
+ info: function(msg) {
+ if (options.logLevel >= logLevel.info) {
+ console.log(msg);
+ }
+ },
+ warn: function(msg) {
+ if (options.logLevel >= logLevel.warn) {
+ console.warn(msg);
+ }
+ },
+ error: function(msg) {
+ if (options.logLevel >= logLevel.error) {
+ console.error(msg);
+ }
}
- }
-});
+ }];
+}
+for(var i = 0; i < options.loggers.length; i++) {
+ less.logger.addListener(options.loggers[i]);
+}
less.env = options.env || (location.hostname == '127.0.0.1' ||
location.hostname == '0.0.0.0' ||
diff --git a/lib/less/logger.js b/lib/less/logger.js
index d073a01..352274d 100644
--- a/lib/less/logger.js
+++ b/lib/less/logger.js
@@ -24,7 +24,7 @@ module.exports = {
},
_fireEvent: function(type, msg) {
for(var i = 0; i < this._listeners.length; i++) {
- var logFunction = this._listeners[i]["type"];
+ var logFunction = this._listeners[i][type];
if (logFunction) {
logFunction(msg);
}
diff --git a/test/browser/common.js b/test/browser/common.js
index 09e2e54..40ec8eb 100644
--- a/test/browser/common.js
+++ b/test/browser/common.js
@@ -10,21 +10,22 @@
// }
// };
-var oldconsole = window.console;
var logMessages = [];
-window.console = {
- warn: function(msg) {
- oldconsole.warn(msg);
+window.less = window.less || {};
+less.loggers = [{
+ info: function(msg) {
+ logMessages.push(msg);
+ },
+ debug: function(msg) {
logMessages.push(msg);
},
- log: function(msg) {
- oldconsole.log(msg);
+ warn: function(msg) {
logMessages.push(msg);
},
error: function(msg) {
- oldconsole.error(msg);
+ logMessages.push(msg);
}
-};
+}];
var testLessEqualsInDocument = function() {
testLessInDocument(testSheet);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list