-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (41 loc) · 1009 Bytes
/
index.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
'use strict';
var winston = require('winston');
var expressWinston = require('express-winston');
module.exports = function () {
var colorize = process.env.NODE_ENV === 'production' ? false : true;
// Logger to capture all requests and output them to the console.
// [START requests]
var requestLogger = expressWinston.logger({
transports: [
new winston.transports.Console({
json: false,
colorize: colorize
})
],
expressFormat: true,
meta: false
});
// [END requests]
// Logger to capture any top-level errors and output json diagnostic info.
// [START errors]
var errorLogger = expressWinston.errorLogger({
transports: [
new winston.transports.Console({
json: true,
colorize: colorize
}),
]
});
// [END errors]
return {
requestLogger: requestLogger,
errorLogger: errorLogger,
error: winston.error,
warn: winston.warn,
info: winston.info,
log: winston.log,
verbose: winston.verbose,
debug: winston.debug,
silly: winston.silly
};
};