Skip to content

Instantly share code, notes, and snippets.

@stuf
Created September 19, 2014 12:19
Show Gist options
  • Save stuf/a77a9509c0912b162898 to your computer and use it in GitHub Desktop.
Save stuf/a77a9509c0912b162898 to your computer and use it in GitHub Desktop.
Generic console object shim for older browsers
'use strict';
var _ = require('underscore');
module.exports = function () {
var noop = function () {};
var args = [
"log", "info", "warn", "error", "debug", "trace", "dir", "group", "groupCollapsed",
"groupEnd", "time", "timeEnd", "profile", "profileEnd", "dirxml", "assert",
"count", "markTimeline", "timeStamp", "clear"
];
if (!('console' in window)) window.console = {};
_.each(args, function (arg) {
if (window.console[arg] == null)
window.console[arg] = noop;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment