]> git.r.bdr.sh - rbdr/cologne/blob - lib/formatters/ansi.js
25ad2565b2813e6a8cb15aee07a67a6144695697
[rbdr/cologne] / lib / formatters / ansi.js
1 (function (global) {
2 var Module;
3
4 // Load up dependencies
5 if (typeof require === 'function') {
6 require('colors');
7 var Ne = require('neon');
8 Module = Ne.Module;
9 } else {
10 Module = global.Module;
11 }
12
13 var Cobalt = {};
14 Module(Cobalt, 'Formatter')({});
15
16 Cobalt.Formatter.Ansi = Module(Cobalt.Formatter, 'Ansi')({
17 format : function (logObject, opts){
18 var indent,
19 message;
20
21 indent = Array(logObject._indentLevel + 1).join(' ');
22
23 message = indent + logObject.message;
24
25 switch(logObject._level) {
26 case 0:
27 case 1:
28 case 2:
29 case 3:
30 return message.red;
31 case 4:
32 return message.yellow;
33 case 5:
34 case 6:
35 return message.blue;
36 default:
37 return message;
38 }
39 }
40 });
41
42 if (typeof require === 'function') {
43 global.Ansi = Cobalt.Formatter.Ansi;
44 } else {
45 global.Cobalt.Formatter.Ansi = Cobalt.Formatter.Ansi;
46 }
47 }(typeof window !== 'undefined' ? window : (typeof exports !== 'undefined' ? exports : self)));