-
Notifications
You must be signed in to change notification settings - Fork 10
/
winston.js
46 lines (35 loc) · 948 Bytes
/
winston.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
var appRoot = require('app-root-path');
var winston = require('winston');
var level = process.env.LOG_LEVEL || 'verbose'
var options = {
file: {
level:level ,
filename: `${appRoot}/logs/chat-http-server.log`,
handleExceptions: true,
json: false,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false,
format: winston.format.simple()
},
console: {
level: level,
handleExceptions: true,
json: true,
colorize: true,
format: winston.format.simple()
},
};
let logger = winston.createLogger({
transports: [
new (winston.transports.Console)(options.console),
new (winston.transports.File)(options.file),
],
exitOnError: false, // do not exit on handled exceptions
});
logger.stream = {
write: function(message, encoding) {
logger.info(message);
},
};
module.exports = logger;