pinojs / pino-elasticsearch

🌲 load pino logs into Elasticsearch
MIT License
179 stars 67 forks source link

can i use pino-elasticsearch as a module #24

Closed guotie closed 5 years ago

guotie commented 5 years ago

for example:

const pinoms = require('pino-multi-stream')
const pinoEs = require('pino-elasticsearch')({
    host: '192.168.1.220',
    index: 'zb'
})

const logger = pinoms({
    streams: [
      {level: 'error', stream: process.stderr}, // an "error" level destination stream
      {level: 'info', stream: process.stdout}, // an "info" level destination stream
      {stream: pinoEs}
    ]
  })

logger.info({'msg': {'info': 'info'}})
logger.debug('debug')
logger.warn('warn')
logger.error('error')
mcollina commented 5 years ago

I would love to support that! Would you like to send a PR?

guotie commented 5 years ago

https://github.com/pinojs/pino-elasticsearch/pull/25

wennyben commented 5 years ago

for the latest version of pino-elasticsearch, 'node' should be used instead of 'host'

const pinoEs = require('pino-elasticsearch')({ node: '192.168.1.220', index: 'zb' })