Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brettlangdon/ledger
Ledger is an event based NodeJS module used for logging events to stdout, files or MongoDB.
https://github.com/brettlangdon/ledger
Last synced: about 1 month ago
JSON representation
Ledger is an event based NodeJS module used for logging events to stdout, files or MongoDB.
- Host: GitHub
- URL: https://github.com/brettlangdon/ledger
- Owner: brettlangdon
- License: mit
- Created: 2012-07-24T00:23:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-07-31T02:21:46.000Z (over 12 years ago)
- Last Synced: 2024-10-12T22:44:55.589Z (3 months ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#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.log
* `info(msg)` //mapped to console.info
* `warn(msg)` //mapped to console.warn
* `error(msg)` //mapped to console.error
* `now()` //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.log
* `log::info`: (time, msg) //event that gets called after a call to console.info
* `log::warn`: (time, msg) //event that gets called after a call to console.warn
* `log::error`: (time, msg) //event that gets called after a call to console.error