event2log
Little helper module for translating events into log messages.
Will perfectly work with NodeJS 4.0.0 and above.
Example
'use strict';
const events = require( 'events' );
const event2log = require( 'event2log' );
let instanceThrowingEvents = new events.EventEmitter();
const translationTable = {
'event1': ( a, b ) => [ 'log', `Hello ${a}! Are you afraid of ${b}?` ],
'event2': ( c ) => [ 'error', `${c} is watching you!` ]
};
let e2lHandler = event2log( translationTable, instanceThrowingEvents, console );
instanceThrowingEvents.emit( 'event1', "World", "Chuck Norris" );
instanceThrowingEvents.emit( 'event2', "Big Brother" );
e2lHandler();
instanceThrowingEvents.emit( 'event1', "Universe", "human beings" );