Add logger

This commit is contained in:
Francesco Esposito 2019-08-22 17:30:30 +02:00
parent 8042d412f1
commit 61467f2f8a
1 changed files with 27 additions and 0 deletions

27
src/logger.js Normal file
View File

@ -0,0 +1,27 @@
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: 'umbrello-bot' }),
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;