Created
May 29, 2014 17:47
-
-
Save anonymous/a2841d043b60e952f56f to your computer and use it in GitHub Desktop.
console wrapper with debug flag in config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var config = require('./config'); | |
var noop = function () {}; | |
var console = {}; | |
var methods = 'debug error info log warn dir dirxml table trace assert count markTimeline profile profileEnd time timeEnd timeStamp timeline timelineEnd group groupCollapsed groupEnd clear'; | |
var $ = require('jquery-browserify'); | |
$.map(methods.split(/\s/), function (name) { | |
var method = window.console && window.console[name]; | |
console[name] = method ? function () { | |
return config.debug ? method.apply(window.console, arguments) : undefined; | |
} : noop; | |
}); | |
module.exports = console; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment