Last active
December 31, 2015 11:49
-
-
Save spmbt/7982217 to your computer and use it in GitHub Desktop.
console,warn, .info, console.log, .error with max logLevel for output and four String.prototype functions: wcw, wci, wcl, wce.<br>
Examples:<br> wcl(12,'XXX') //i.e. console.log(12,'XXX');<br> 'Error message'.wce(er) //i.e. console.error("'=E='",'Error message', er);<br>
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
(function(w, logLevel, wcA){ var lvl =0 | |
,$x = function(el, h){if(h) for(var i in h) el[i] = h[i]; return el}; | |
for(var i in wcA) //консоль[i] как метод строки или функция | |
w[i] = (function(lvl, wcAI, i){ | |
return function(a){ a = a!==undefined|| arguments.length ? a :''; | |
if(w.console && logLevel <= lvl) | |
Function.prototype.apply.call(w.console[i], w.console, this instanceof String | |
//w.console[i].apply(console, this instanceof String //--for without IE | |
? [wcAI + this +"'"].concat([].slice.call(arguments)) | |
: arguments); | |
else | |
w.console[i] = function(){}; | |
} })(lvl++, wcA[i], {wcw:'warn', wci:'info', wcl:'log', wce:'error'}[i]); | |
w.wcc = w.console.clear; | |
$x(String.prototype, {wcw: w.wcw, wci: w.wci, wcl: w.wcl, wce: w.wce, wcc: w.wcc }); | |
})(window, /*logLevel*/ 0, {wcw:"'-w-", wci:'--', wcl:"'==", wce:"'=E="}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment