Skip to content

Instantly share code, notes, and snippets.

@dataserver
Created August 10, 2022 13:17
Show Gist options
  • Save dataserver/253cf6c9c31b417738a1bcb53e340dcf to your computer and use it in GitHub Desktop.
Save dataserver/253cf6c9c31b417738a1bcb53e340dcf to your computer and use it in GitHub Desktop.
js console wrapper
(function () {
var debug = true;
var methods = [
"assert", "clear", "count", "countReset", "debug", "dir", "dirxml", "error",
"exception", "group", "groupCollapsed", "groupEnd", "info", "log",
"profile", "profileEnd", "table", "time", "timeEnd",
"timeLog", "timeStamp", "trace", "warn"
];
var _cons = (window.console = window.console || {});
methods.forEach(method => {
if (!debug) {
_cons[method] = function () { };
} else {
if (!_cons[method]) {
_cons[method] = function () { };
}
}
});
window.console = _cons;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment