mahnunchik / mag

Mag is the streaming logger for NodeJS
https://npmjs.org/mag
MIT License
54 stars 3 forks source link

Simpler design #5

Open AlgoTrader opened 10 years ago

AlgoTrader commented 10 years ago

The design of mag is modular, but it is certainly overkill for most of simple cases. I would suggest not the streams but "middleware" concept. This is the way express.js works, Faraday or Faye from Ruby world.

How I like logger to be:

var log = require('mag').logger(domain);
log.use( mag.colorFormatter )
log.use( function(item, cb)  {...} );

log.error('Oppa Ghannam Style');

The concept of middleware is it is some function that is called by module when it needs something. express.js is extremely simple - all I need is a single function for most of cases

mahnunchik commented 10 years ago

I think this feature is suitable for mag-hub module. Additional it is possible to implement both way: pipes and middlewares.