2017-06-19 22:10:06 +02:00
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
module.exports = (winston, logLevel, logDir) => {
|
|
|
|
if (!fs.existsSync(logDir)) {
|
|
|
|
fs.mkdirSync(logDir);
|
|
|
|
}
|
|
|
|
|
2017-06-20 04:34:34 +02:00
|
|
|
winston.configure({
|
|
|
|
transports: [
|
2017-06-20 04:46:39 +02:00
|
|
|
new (winston.transports.Console)({
|
2017-06-20 04:34:34 +02:00
|
|
|
level : logLevel,
|
|
|
|
timestamp : false,
|
|
|
|
colorize : true,
|
|
|
|
prettyPrint: true,
|
|
|
|
}),
|
2017-06-20 04:46:39 +02:00
|
|
|
new (winston.transports.File)({
|
2017-06-20 05:22:23 +02:00
|
|
|
filename : `${logDir}speechLogs.log`,
|
|
|
|
level : logLevel,
|
|
|
|
json : false,
|
|
|
|
timestamp : true,
|
|
|
|
colorize : true,
|
|
|
|
prettyPrint : true,
|
|
|
|
handleExceptions : true,
|
|
|
|
humanReadableUnhandledException: true,
|
2017-06-20 04:34:34 +02:00
|
|
|
}),
|
2017-06-20 04:46:39 +02:00
|
|
|
],
|
2017-06-20 04:34:34 +02:00
|
|
|
});
|
2017-06-19 22:10:06 +02:00
|
|
|
|
|
|
|
winston.error('Level 0');
|
|
|
|
winston.warn('Level 1');
|
|
|
|
winston.info('Level 2');
|
|
|
|
winston.verbose('Level 3');
|
|
|
|
winston.debug('Level 4');
|
|
|
|
winston.silly('Level 5');
|
|
|
|
};
|