Skip to content

Instantly share code, notes, and snippets.

Created May 29, 2014 17:47
Show Gist options
  • Save anonymous/a2841d043b60e952f56f to your computer and use it in GitHub Desktop.
Save anonymous/a2841d043b60e952f56f to your computer and use it in GitHub Desktop.
console wrapper with debug flag in config.js
'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