]>
git.r.bdr.sh - rbdr/cologne/blob - lib/formatters/token.js
1 Module(Cobalt
.Formatter
, 'Token')({
2 formatString : "{{message}}",
3 replaceRule : /{{(.*?)}}/g,
6 format : function (logObject
, opts
){
7 var indent
, indentSize
,
8 separatorLength
, separatorType
,
10 indentSize
= logObject
._indentLevel
|| 0;
12 indent
= Array(indentSize
+ 1).join(' ');
14 if (logObject
._separator
) {
15 separatorLength
= logObject
._separatorLength
|| this.separatorLength
;
16 separatorType
= logObject
._separatorType
|| this.separatorType
;
17 output
= indent
+ Array(separatorLength
- indentSize
+ 1).join(separatorType
);
19 output
= indent
+ this.parseFormatString(logObject
, opts
.formatString
);
23 output
= this.colorize(logObject
._level
, output
);
29 parseFormatString : function (logObject
, formatString
) {
30 var resultString
= '';
31 if (typeof formatString
=== 'undefined') {
32 formatString
= this.formatString
;
35 resultString
= formatString
.replace(this.replaceRule
, function(match
, paren
){
36 return logObject
[paren
] || "-";
42 colorize : function (level
, message
) {
50 return message
.yellow
;