]>
git.r.bdr.sh - rbdr/cologne/blob - lib/loggers/file.js
1 var fs
= require('fs');
3 Class(Cobalt
.Logger
, 'File')({
8 init : function (config
) {
10 for (property
in config
) {
11 this[property
] = config
[property
];
15 this._stream
= fs
.createWriteStream(this.file
, {flags: 'a'});
19 var i
, message
= [], severity
;
21 for (i
= 0; i
< arguments
.length
; i
++) {
22 // We're not formatting objects for now.
24 if (!arguments
[i
].__skipConsole
&& !arguments
[i
].message
.__skipConsole
) {
25 message
.push(this.format(arguments
[i
]));
27 severity
= arguments
[i
]._level
32 for (i
= 0; i
< message
.length
; i
++) {
33 this._stream
.write(message
[i
] + '\n');
37 format : function (logObject
) {
39 if (typeof logObject
.message
=== 'object') {
40 return logObject
.message
;
42 return this.formatter
.format(logObject
, this.formatterOpts
);
45 return Cobalt
.stringify(logObject
);