]> git.r.bdr.sh - rbdr/cologne/blob - lib/loggers/console.js
Updates bower.json file
[rbdr/cologne] / lib / loggers / console.js
1 Class(Cobalt.Logger, 'JsConsole')({
2 prototype : {
3 console : null,
4 formatterOpts : {},
5
6 init : function (config) {
7 var logger = this,
8 property;
9
10 if (config) {
11 for (property in config) {
12 logger[property] = config[property];
13 }
14 }
15
16 if (!logger.console) {
17 logger.console = console;
18 }
19 },
20
21 log : function () {
22 var i, message = [], severity;
23
24 for (i = 0; i < arguments.length; i++) {
25 // We're not formatting objects for now.
26
27 if (!arguments[i].__skipConsole && !arguments[i].message.__skipConsole) {
28 if (typeof arguments[i].message === 'object') {
29 message.push(arguments[i].message);
30 } else {
31 message.push(this.format(arguments[i]));
32 }
33 if (!severity) {
34 severity = arguments[i]._level
35 }
36 }
37 }
38
39 switch (severity){
40 case 0:
41 case 1:
42 case 2:
43 case 3:
44 this.console.error.apply(this.console, message);
45 break;
46 case 4:
47 this.console.warn.apply(this.console, message);
48 break;
49 case 5:
50 case 6:
51 this.console.info.apply(this.console, message);
52 break;
53 case 7:
54 default:
55 this.console.log.apply(this.console, message);
56 break;
57 }
58 },
59
60 format : function (logObject) {
61 // Usually what you want to do here is format. Preferably using
62 // someone inside Cobalt.Formatter
63 if (this.formatter) {
64 return this.formatter.format(logObject, this.formatterOpts);
65 }
66
67 return logObject.message;
68 }
69 }
70 });