[Pkg-javascript-commits] [sockjs-client] 287/350: better logging functions

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:04:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit 2133e57b827b053c0133a459c080b0ad46f792af
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Sun Feb 1 12:43:19 2015 -0500

    better logging functions
---
 lib/main.js      |  2 +-
 lib/utils/log.js | 16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/main.js b/lib/main.js
index 4cbae08..bc011d4 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -47,7 +47,7 @@ function SockJS(url, protocols, options) {
   // non-standard extension
   options = options || {};
   if (options.protocols_whitelist) {
-    log.info("Warning: 'protocols_whitelist' is DEPRECATED. Use 'transports' instead.");
+    log.warn("'protocols_whitelist' is DEPRECATED. Use 'transports' instead.");
   }
   this._transportsWhitelist = options.transports;
   this._server = options.server || random.numberString(1000);
diff --git a/lib/utils/log.js b/lib/utils/log.js
index 976db73..4e73068 100644
--- a/lib/utils/log.js
+++ b/lib/utils/log.js
@@ -1,9 +1,11 @@
 'use strict';
 
-module.exports = {
-  info: function() {
-    if (global.console && global.console.log && global.console.apply) {
-      global.console.log.apply(global.console, arguments);
-    }
-  }
-};
+var logObject = {};
+['log', 'debug', 'warn'].forEach(function (level) {
+  var levelExists = global.console && global.console[level] && global.console[level].apply;
+  logObject[level] = levelExists ? function () {
+    return global.console[level].apply(global.console, arguments);
+  } : (level === 'log' ? function () {} : logObject.log);
+});
+
+module.exports = logObject;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list