-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.js
34 lines (30 loc) · 846 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
const { createLogger, format, transports } = require('winston');
const { combine, printf } = format;
require('winston-daily-rotate-file');
const formatter = printf(
(args) => `${new Date()} - ${args.level}: ${args.message}`
)
const logger = createLogger({
format: combine(formatter),
transports:[
new transports.DailyRotateFile({
filename: '%DATE%.log',
handleException: true,
json: false,
colorize: true,
maxsize: 5242880,
maxFiles: 5,
datePattern: 'YYYY-MM-DD',
prepend: true,
level: process.env.LOGGING_LEVEL || 'info',
dirname: '/var/log',
})
],
exitOnError:false
});
module.exports = logger;
module.exports.stream = {
write: (message) =>{
logger.info(message);
}
};