Last active
December 9, 2015 16:28
-
-
Save vermilion1/4296485 to your computer and use it in GitHub Desktop.
Log plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* 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