-
Notifications
You must be signed in to change notification settings - Fork 0
/
y.js
36 lines (32 loc) · 1.09 KB
/
y.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var util = require('util');
module.exports = y;
function y() {
y.settings = y.settings || {};
var err = new Error();
Error.captureStackTrace(err, arguments.callee);
var stack = err.stack.split('\n');
var stackSize = y.settings.stackSize || 1;
for (var i=1; i<=stackSize && i<stack.length; i++) {
console.log('\u001b[36m%s|%s\u001b[39m',
new Date().toJSON(), stack[i].trim());
}
var depth = (y.settings.depth === null)?null:y.settings.depth || 2;
for (var i=0; i<arguments.length; i++){
var type = Object.prototype.toString.call(arguments[i]);
console.log('\u001b[4m%s\u001b[24m', type);
console.log(util.inspect(arguments[i], true, depth, true));
}
return y;
}
y.set = function (settings) {
settings = settings || {};
if (settings.title) {
console.log('\u001b[31m%s\u001b[39m', settings.title);
}
y.settings = y.settings || {};
y.settings.depth = (settings.depth === null)?
null:
settings.depth || y.settings.depth;
y.settings.stackSize = settings.stackSize || y.settings.stackSize;
return y;
};