formatString : "{{message}}",
replaceRule : /{{(.*?)}}/g,
separatorLength : 60,
+ isoDate : true,
separatorType : "-",
format : function (logObject, opts){
var indent, indentSize,
separatorLength, separatorType,
- output;
+ output, property;
indentSize = logObject._indentLevel || 0;
+ // Extend opts
+ if (opts) {
+ for (property in opts) {
+ if (opts.hasOwnProperty(property)) {
+ this[property] = opts[property];
+ }
+ }
+ }
+
indent = Array(indentSize + 1).join(' ');
if (logObject._separator) {
separatorType = logObject._separatorType || this.separatorType;
output = indent + Array(separatorLength - indentSize + 1).join(separatorType);
} else {
- output = indent + this.parseFormatString(logObject, opts.formatString);
+ output = indent + this.parseFormatString(logObject, this.formatString);
}
- if (opts.ansiColor) {
+ if (this.ansiColor) {
output = this.colorize(logObject._level, output);
}
}
resultString = formatString.replace(this.replaceRule, function(match, paren){
+ var date;
+ if (paren === "_timestamp" && this.isoDate) {
+ date = new Date(logObject[paren]);
+ return date.toISOString();
+ }
return logObject[paren] || "-";
- });
+ }.bind(this));
return resultString;
},