]>
git.r.bdr.sh - rbdr/cologne/blob - lib/loggers/console.js
c8e3036bc8497ca44d8a5abaf592bdbe348b4c22
4 // Load up dependencies
5 if (typeof require
=== 'function') {
6 var Ne
= require('neon');
10 Module
= global
.Module
;
15 Module(Cobalt
, 'Logger')({});
17 Cobalt
.Logger
.JsConsole
= Class(Cobalt
.Logger
, 'JsConsole')({
22 init : function (config
) {
27 for (property
in config
) {
28 logger
[property
] = config
[property
];
32 if (!logger
.console
) {
33 logger
.console
= console
;
38 var i
, message
= [], severity
;
40 for (i
= 0; i
< arguments
.length
; i
++) {
41 // We're not formatting objects for now.
43 if (!arguments
[i
].__skipConsole
&& !arguments
[i
].message
.__skipConsole
) {
44 if (typeof arguments
[i
].message
=== 'object') {
45 message
.push(arguments
[i
].message
);
47 message
.push(this.format(arguments
[i
]));
50 severity
= arguments
[i
]._level
60 this.console
.error
.apply(this.console
, message
);
63 this.console
.warn
.apply(this.console
, message
);
67 this.console
.info
.apply(this.console
, message
);
71 this.console
.log
.apply(this.console
, message
);
76 format : function (logObject
) {
77 // Usually what you want to do here is format. Preferably using
78 // someone inside Cobalt.Formatter
80 return this.formatter
.format(logObject
, this.formatterOpts
);
83 return logObject
.message
;
88 if (Cobalt
.Logger
.JsConsole
.__objectSpy
) {
89 Cobalt
.Logger
.JsConsole
.__objectSpy
.destroy();
92 if (typeof require
=== 'function') {
93 global
.JsConsole
= Cobalt
.Logger
.JsConsole
;
95 global
.Cobalt
.Logger
.JsConsole
= Cobalt
.Logger
.JsConsole
;
97 }(typeof window
!== 'undefined' ? window : (typeof exports
!== 'undefined' ? exports : self
)));