31 lines
915 B
JavaScript
31 lines
915 B
JavaScript
"use strict";
|
|
var { winston, transports, createLogger, format } = require('winston');
|
|
var path = require('path');
|
|
// Set this to whatever, by default the path of the script.
|
|
var logPath = './logs/';
|
|
const tsFormat = () => (new Date().toISOString());
|
|
const errorLog = createLogger({
|
|
format: format.combine(format.timestamp(), format.json()),
|
|
transports: [
|
|
new transports.File({
|
|
filename: path.join(logPath, 'errors.log'),
|
|
timestamp: tsFormat,
|
|
level: 'debug'
|
|
})
|
|
]
|
|
});
|
|
const accessLog = createLogger({
|
|
format: format.combine(format.timestamp(), format.json()),
|
|
transports: [
|
|
new transports.File({
|
|
filename: path.join(logPath, 'access.log'),
|
|
timestamp: tsFormat,
|
|
level: 'info'
|
|
})
|
|
]
|
|
});
|
|
module.exports = {
|
|
errorLog: errorLog,
|
|
accessLog: accessLog
|
|
};
|
|
//# sourceMappingURL=logger.js.map
|