-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.js
48 lines (41 loc) · 888 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
41
42
43
44
45
46
47
48
const bunyan = require("bunyan");
const config = require('./config/handler').getConfig()
const ERR_SERIALIZER = (err) => {
return {
...err,
...bunyan.stdSerializers.err(err)
};
};
const REQ_SERIALIZER = (req) => {
return {
...bunyan.stdSerializers.req(req),
hostname: req.hostname,
body: req.body,
cookies: req.cookies,
originalUrl: req.originalUrl,
query: req.query
}
};
const RES_SERIALIZER = (res) => {
return {
...bunyan.stdSerializers.res(res),
headers: res._headers
};
};
const logger = bunyan.createLogger({
name: "hoppedIn",
src: true,
serializers: {
err: ERR_SERIALIZER,
req: REQ_SERIALIZER,
res: RES_SERIALIZER
},
streams: [{
path: config.LOG.PATH,
level: config.LOG.LEVEL
}]
});
logger.logSentry = function(err) {
//TODO sentry
};
module.exports = logger;