|
|
14 years ago | |
|---|---|---|
| example | 14 years ago | |
| lib | 14 years ago | |
| .gitignore | 14 years ago | |
| LICENSE | 14 years ago | |
| README.md | 14 years ago | |
| package.json | 14 years ago | |
#Ledger Ledger is an event based NodeJS module used for logging to various locations.
By default Ledger can overwrite console.log, console.info, console.warn and console.error to allow all output, even output from other modules.
##Installation:
npm install ledger
##Usage:
//this will output all messages to the file "my/file.log"
var ledger = (require('ledger');
var logger = ledger.createLogger( {}, [
new ledger.transactions.file( { logFile: 'my/file.log' } ),
]);
ledger.on('log::error', function(time, msg){
//do something special with errors
});
ledger.on('log::*', function(time, msg){
//log catchall
});
console.log('log');
console.info('info');
console.warn('warn');
console.error('error');
##Options:
separator: String //separator used when building messages, Default: ' > 'timeFormatter: Function(date) //function used when formatting Date object to a string, Default: function(date){ return date.toString(); }##Methods:
log(msg) //mapped to console.loginfo(msg) //mapped to console.infowarn(msg) //mapped to console.warnerror(msg) //mapped to console.errornow() //get the current time using timeFormatter setting_log(msg,parts) // raw logging, do not use##Events:
log::log: (time, msg) //event that gets called after a call to console.loglog::info: (time, msg) //event that gets called after a call to console.infolog::warn: (time, msg) //event that gets called after a call to console.warnlog::error: (time, msg) //event that gets called after a call to console.error