|
|
@ -26,40 +26,19 @@ var dateFormat = require('./date_format')
|
|
|
|
OFF: "grey"
|
|
|
|
OFF: "grey"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function formatLogData(logData) {
|
|
|
|
function wrapErrorsWithInspect(items) {
|
|
|
|
var output = ""
|
|
|
|
return items.map(function(item) {
|
|
|
|
, data = Array.isArray(logData) ? logData.slice() : Array.prototype.slice.call(arguments)
|
|
|
|
if ((item instanceof Error) && item.stack) {
|
|
|
|
, format = data.shift();
|
|
|
|
return { inspect: function() { return util.format(item) + '\n' + item.stack; } };
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof format === "string") {
|
|
|
|
|
|
|
|
output = format.replace(replacementRegExp, function(match) {
|
|
|
|
|
|
|
|
switch (match) {
|
|
|
|
|
|
|
|
case "%s":
|
|
|
|
|
|
|
|
return data.shift().toString();
|
|
|
|
|
|
|
|
case "%d":
|
|
|
|
|
|
|
|
return new Number(data.shift());
|
|
|
|
|
|
|
|
case "%j":
|
|
|
|
|
|
|
|
return JSON.stringify(data.shift());
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return match;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//put it back, it's not a format string
|
|
|
|
return item;
|
|
|
|
data.unshift(format);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.forEach(function (item) {
|
|
|
|
|
|
|
|
if (output) {
|
|
|
|
|
|
|
|
output += ' ';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
output += util.inspect(item);
|
|
|
|
|
|
|
|
if (item && item.stack) {
|
|
|
|
|
|
|
|
output += "\n" + item.stack;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
function formatLogData(logData) {
|
|
|
|
|
|
|
|
var data = Array.isArray(logData) ? logData : Array.prototype.slice.call(arguments);
|
|
|
|
|
|
|
|
return util.format.apply(util, wrapErrorsWithInspect(data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var styles = {
|
|
|
|
var styles = {
|
|
|
|