Last active
August 29, 2015 14:18
-
-
Save antonlvovych/30574e7650a380b132aa to your computer and use it in GitHub Desktop.
Simple console.log wrapper with colors and labels
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 () { | |
var options = { | |
name: 'logger', | |
label: '❤', | |
date: true, | |
color: '#2980b9' | |
}; | |
window[options.name] = function () { | |
var label = options.label + (options.date ? ('[' + Date() + ']') : '') | |
, _arg = []; | |
label && _arg.push(('%c' + label)); | |
options.color && _arg.push('color:' + options.color); | |
console.log.apply(console, _arg.concat(Array.prototype.slice.apply(arguments))); | |
}; | |
})(); |
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
/* ~200 bytes */ | |
;(function(){var o={n:"logger",l:"❤",d:!0,c:"#2980b9"};window[o.n]=function(){var l=o.l+(o.d?"["+Date()+"]":""),a=[];l&&a.push("%c"+l);o.c&&a.push("color:"+o.c);console.log.apply(console,a.concat(Array.prototype.slice.apply(arguments)))}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment