-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathlogger.js
40 lines (33 loc) · 904 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
31
32
33
34
35
36
37
38
39
40
const Winston = require ('winston'),
ExpressWinston = require ('express-winston'),
WinstonGraylog2 = require ('winston-graylog2')
;
const GRAYLOG_HOST = process.env.GRAYLOG_HOST || 'evil.com',
GRAYLOG_PORT = process.env.GRAYLOG_PORT || 12201,
NODE_ENV = process.env.NODE_ENV || 'development'
;
const GrayLogger = new WinstonGraylog2 ({
name: 'troublemaker-backend',
level: 'debug',
silent: false,
handleExceptions: true,
prelog: function (msg) {
return msg.trim ()
},
graylog: {
servers: [{ host: GRAYLOG_HOST, port: GRAYLOG_PORT }],
facility: 'troublemaker-backend',
bufferSize: 1400
},
staticMeta: {
env: NODE_ENV
}
})
const expressLogger = ExpressWinston.logger ({
transports: [GrayLogger],
meta: true,
msg: "HTTP {{req.method}} {{req.url}}",
expressFormat: true,
colorize: false
})
module.exports.expressLogger = expressLogger