Ledger is an event based NodeJS module used for logging events to stdout, files or MongoDB.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

28 lines
644 B

var util = require('util');
var transaction = require('../transaction');
var fs = require('fs');
var file = function(options){
transaction.call(this,options);
if( !(typeof this.options.logFile === 'string') ){
this.options.logFile = 'ledger.log';
}
};
util.inherits(file,transaction);
file.prototype = {
log: function(msg,parts){
if( typeof this.options.logFile === 'string'){
fs.open(this.options.logFile, 'a', function(err,fd){
if( err ) throw err;
fs.write( fd, msg+'\n', null, null, null, function(err){
if( err ) throw err;
fs.close(fd);
});
});
}
},
};
module.exports = file;