Kaizen
ExpressJS Log Middleware
Features
- stores log information in a persistence layer of your choice
- pretty prints colored and structutred output
- implements base16 color schemes and allows to create custom ones
- plug-in system to create your own DB adapters
Install
npm install kaizen
Usage
Basic
var Kaizen = ; var kaizen = ; app; //your routes here app;
Choose a different color scheme
var config = style: 'railscasts'; var kaizen = config; app; //your routes here app;
Use your color scheme
var config = style: '00': '#001100' '01': '#003300' '02': '#005500' '03': '#007700' '04': '#009900' '05': '#00bb00' '06': '#00dd00' '07': '#00ff00' '08': '#007700' '09': '#009900' '0A': '#007700' '0B': '#00bb00' '0C': '#005500' '0D': '#009900' '0E': '#00bb00' '0F': '#005500' ; var kaizen = config; app;
Write to MongoDB
var Kaizen = ;var k_mongodb = ; var config = uri: 'mongodb://user:password@localhost/yourdb' collection: 'foobar' stdout: false style: 'railscasts'var kaizen = config k_mongodb; app; //your routes here app;
Create your own Adapter
// Write a module which exports 2 functions: connect() and save() exports { // handle the connection to DB // config arg is the one you passed to Kaizen constructor // example: { // uri: 'mongodb://user:password@localhost/yourdb', // collection: 'foobar', // stdout: false, // style: 'railscasts' // }}; exports { // handles req,res and error messages parsing/saving to DB // obj example: // { // "req": { // "headers": { // "user-agent": "curl/7.22.0 (x86_64-pc-linux-gnu)", // "host": "127.0.0.1:3000", // "accept": "*/*" // }, // "body": {}, // "method": "GET", // "url": "/", // "protocol": "http", // "version": "1.1" // } // } }; // require and pass it to kaizen with your config options:var kaizen = ;var yourmod = ; var kaizen = config yourmod; app;
sample mongodb adapter for reference: https://github.com/Shoen/kaizen-mongodb