1
0
mirror of https://github.com/franjsco/tick3t-api synced 2024-12-22 13:05:47 +01:00

add logger

This commit is contained in:
Francesco Esposito 2019-08-07 11:44:31 +02:00
parent ef9fb12a99
commit 4f85873d1f

29
src/logger.js Normal file
View File

@ -0,0 +1,29 @@
import winston from 'winston';
const { format } = winston;
const customFormat = format.printf(({
level,
message,
label,
timestamp,
}) => `${timestamp} [${label}] ${level}: ${message}`);
const logger = winston.createLogger({
level: 'info',
format: format.combine(
format.label({ label: 'tick3t-api' }),
format.timestamp(),
customFormat,
),
defaultMeta: { service: 'user-service' },
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
],
});
export default logger;