반응형
function _help(msg) {
var o;
switch (typeof(msg)) {
case 'undefined':
case 'boolean':
case 'number':
case 'string': o = msg;
break;
case 'function': o = msg.toString();
break;
case 'object': if (msg === null) {
o = 'null';
}
else if (Array.isArray(msg)) {
o = msg;
}
else {
o = JSON.parse(JSON.stringify(msg));
}
break;
default: console.warn('log.out: undeterminable type: {0}'.format());
o = msg;
}
return o;
}
function err() {
var args = Array.prototype.slice.call(arguments);
for (var i = 0, len = args.length; i < len; i++) {
if (args[i] && args[i].stack) { // PE if this is an actual js error obj, just print the stack
console.error(args[i].stack);
}
else {
console.error(_help(args[i]));
}
}
console.trace();
console.log('');
}
function log() {
var args = Array.prototype.slice.call(arguments);
for (var i = 0, len = args.length; i < len; i++) {
console.log(_help(args[i]));
}
console.trace();
console.log('');
}
반응형
'개발일지 > JS' 카테고리의 다른 글
[jQuery] element append/remove animate (0) | 2016.05.20 |
---|---|
[jQuery] 스크롤 최하단 자동 포커스(auto scroll to bottom of page with jquery) (0) | 2016.05.20 |
[JS] OwlCarousel.js ver.1.3.2 (0) | 2016.04.14 |
[jQuery] jquery height() incorrect work in chrome (0) | 2016.03.24 |
[jQuery] jquery timer, javascript countdown (타이머 예제) (0) | 2016.03.02 |