UNPKG

get-express-starter

Version:

Get production ready express boilerplate with a single command

27 lines (23 loc) 708 B
const winston = require('winston'); const env = require('./env'); const enumerateErrorFormat = winston.format((info) => { if (info instanceof Error) { Object.assign(info, { message: info.stack }); } return info; }); const logger = winston.createLogger({ level: env.mode === 'development' ? 'debug' : 'info', format: winston.format.combine( enumerateErrorFormat(), env.mode === 'development' ? winston.format.colorize() : winston.format.uncolorize(), winston.format.splat(), winston.format.printf(({ level, message }) => `${level}: ${message}`) ), transports: [ new winston.transports.Console({ stderrLevels: ['error'], }), ], }); module.exports = logger;