-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
30 lines (20 loc) · 934 Bytes
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// (function (exports, require, module, __filename, __dirname) { // Module wrapping function
const EventEmitter = require('events') // Loading Event Module - Node JS __< with event emiiter class >
// const { emitWarning } = require('process')
// const emitter = new EventEmitter()
console.log(__filename) // gives current filename
console.log(__dirname) // gives current directory name
// var x =;
var url = 'http://mylogger.io/log';
class Logger extends EventEmitter{
log(message) {
// Send an HTTP request
console.log(message);
// Raise an Event
emitter.emit('messageLogged') // This emit method iterates over all the registered listeners and calls them synchronously
this.emit('messageLogged' , 1 , 'url')
this.emit('messageLogged' , { id: 1 , url: 'http://'} )
}
}
module.exports = Logger;
// })