@zhike/logger
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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' })

Readme

Keywords

none

Package Sidebar

Install

npm i @zhike/logger

Weekly Downloads

0

Version

0.0.4

License

ISC

Unpacked Size

13.4 kB

Total Files

13

Last publish

Collaborators

  • misakisaysyes
  • smartfe
  • jayi
  • zhiker
  • maintao
  • renxing
  • shenggao