I_Jemin

Event is bounded to single Event Emitter, event call won't be global

......@@ -6,9 +6,10 @@ emitter.on('messageLogged', (arg) => {
console.log('Listener called',arg);
});
emitter.on('logging', (e) => { console.log('Loggin Event',e);});
const log = require('./logger');
log('message');
emitter.emit('messageLogged', {id: 1, url: 'http://' });
// Raise: logging (data: message)
emitter.emit('logging','Jemin');
......
console.log(__filename);
console.log(__dirname);
var url = 'http://mylogger.io/log';
const EventEmitter = require('events');
const emitter = new EventEmitter();
var url = 'http:mylogger.io/log';
function log(message) {
// Send an HTTP request
console.log(message);
emitter.emit('messageLogged', {id: 1, url: 'http://' });
}
module.exports = log;
......