Logger Facade Nodejs
Simple node module to work as logger facade.
This simple logger facade allows you to hook plugins to execute async logging.
The logger facade contract:
// register a plugin on loggerLogger;// retrieve the list of plugin namesLoggerplugins;// clean up the list of pluginsLogger;// retrieve a logger with the specified namevar log = Logger;
The logger contract is:
log; // return if in debug or trace levellog;log;log;log;log;log;log;log;log;log;
The logger uses util.format to build log message.
The plugins must follow this contract:
plugin = name: 'mock' isDebug: Function trace: Function debug: Function info: Function warn: Function error: Function;
How to use it
Install it:
npm install logger-facade-nodejs
Set up plugins
var Logger = ; var plugin = name: 'mock' isDebug: Function trace: Function debug: Function info: Function warn: Function error: Function; Logger; var log = Logger; log; log;
Available plugins
- Console
- Airbrake (Will be developed soon)
- Elasticsearch (Will be developed soon)
** Do you need some other plugin?**
Feel free to create one and get in touch with me, that i will add it to this list.
Using peer dependency
This module work as singleton, if you need to distribute a library that uses it due to npm Module Cache Caveats you need to add it as peer dependency.
Example:
// The App module// The framework module
Contributing
Bug fixes and new features are of course very welcome!
To get started developing:
- Install Grunt
- Install dependencies with
npm install
- Run the test suite with
npm test
Please accompany any Pull Requests with the relevant test cases and make sure everything else still passes :).
Credits
Shout out to @pjanuario.