A logger has following features:
*. support log to console, file, elasticsearch, kafka, sentry
*. log to file support rotating by time
*. customized formatter
*. supported levels: fatal, error, warning, info, debug
Demo
const logger = new Logger({
console: {},
elasticsearch: {
endpoint: '172.16.3.2:19200',
defaultIndex: 'demo',
level: 'warning',
},
file: {
rotateFilename: '[logs/demo_]YYYY-MM-DD[.log]',
level: 'info',
},
}, {
basicInfo: { project: 'crm' },
})
logger.debug('debug 1')
logger.info('info 1')
logger.info('info 2')
logger.error('error 1', { index__: 'demo1' })