forked from strapi/migration-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.js
28 lines (24 loc) · 786 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
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;
const myFormat = printf( ({ level, message, timestamp }) => {
return `${timestamp} ${level}: ${message}`;
});
var filename = module.filename.split('/').slice(-1);
const logger = createLogger({
level: 'debug',
format: combine(
label({ label: filename }),
timestamp(),
myFormat
),
transports: [
//
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
//
new transports.File({ filename: 'error.log', level: 'error' }),
new transports.Console({level: 'verbose'}),
new transports.File({ filename: 'combined.log' })
]
});
module.exports = logger;