This commit is contained in:
Josh Burman 2019-03-14 19:00:48 -04:00
parent 57f2aeaa2e
commit bc04e7892c

View File

@ -5,28 +5,26 @@ var path = require('path');
var logPath = './logs/'; var logPath = './logs/';
const tsFormat = () => (new Date().toISOString()); const tsFormat = () => (new Date().toISOString());
const logFormat = format.combine(format.timestamp(), format.json()) const logFormat = format.combine(format.timestamp(), format.json());
function loggerTransports(logName: string, logLevel: string) {
return [
new transports.File({
filename: path.join(logPath, `${logName}.log`),
timestamp: tsFormat,
level: logLevel
})
]
};
const errorLog = createLogger({ const errorLog = createLogger({
format: logFormat, format: logFormat,
transports: [ transports: loggerTransports('error', 'debug')
new transports.File({
filename: path.join(logPath, 'errors.log'),
timestamp: tsFormat,
level: 'debug'
})
]
}); });
const accessLog = createLogger({ const accessLog = createLogger({
format: logFormat, format: logFormat,
transports: [ transports: loggerTransports('access', 'info')
new transports.File({
filename: path.join(logPath, 'access.log'),
timestamp: tsFormat,
level: 'info'
})
]
}); });