Skip to content

Instantly share code, notes, and snippets.

@vermilion1
Last active December 9, 2015 16:28
Show Gist options
  • Save vermilion1/4296485 to your computer and use it in GitHub Desktop.
Save vermilion1/4296485 to your computer and use it in GitHub Desktop.
Log plugin
/*!
* Log plugin
* Copyright 2012, Vitaliy Petrychuk
*/
;(function(window) {
var log = function() {
if (window.debug_mode) {
var stack = (new Error).stack;
var args = arguments.length === 1 ? arguments[0] : Array.prototype.slice.call(arguments, 0).join(' ');
console.log(args + (stack ? '\n' + stack.split('\n')[3].trim() : ''));
}
};
window.log = function() { log.apply(this, ['->'].concat(Array.prototype.slice.call(arguments, 0))) };
window.err = function() { log.apply(this, ['-!'].concat(Array.prototype.slice.call(arguments, 0))) };
}(window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment