Skip to content

Instantly share code, notes, and snippets.

@katopz
Created November 9, 2016 08:37
Show Gist options
  • Save katopz/1526964b4854c5c9796b43ed9af7b289 to your computer and use it in GitHub Desktop.
Save katopz/1526964b4854c5c9796b43ed9af7b289 to your computer and use it in GitHub Desktop.
Playing with console
// Will print... [2016-11-09T07:52:09.303Z] foo bar
// ES6
var _log = _log || console.log;
console.log = (...arguments) => {
arguments.unshift(`[${new Date().toISOString()}]`)
_log.apply(console, arguments);
};
console.log('foo', 'bar');
// ES5
var _log = _log || console.log;
console.log = function() {
const args = Array.prototype.slice.call(arguments);
args.unshift(`[${new Date().toISOString()}]`)
_log.apply(console, args);
};
console.log('foo', 'bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment