@zhike/logger
v0.0.4
Published
A logger has following features:
Downloads
1
Keywords
Readme
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', // es server endpoint
defaultIndex: 'demo', // default target index
level: 'warning', // log level under warning is supressed
},
file: {
rotateFilename: '[logs/demo_]YYYY-MM-DD[.log]', // rotate by day
level: 'info', // log level under info is supressed
},
}, {
basicInfo: { project: 'crm' },
})
logger.debug('debug 1')
logger.info('info 1')
logger.info('info 2')
// log to es with index 'demo1' but not default 'demo'
logger.error('error 1', { index__: 'demo1' })