0.0.3 • Published 7 months ago
graylog-stream v0.0.3
Graylog Stream
graylog-stream
is for streaming data to graylog over TCP. You can either pipe
data to it, use it as a module, or use it as a worker_thread. It is designed
to be compatible with pino, and can be used as a pino transport stream.
Usage Examples
As a command line tool:
echo '{"hello":"world"}' | graylog-stream -c config.json
As a module:
const graylogStream = require('graylog-stream')
const stream = graylogStream({ host: 'localhost', port: 12201 })
stream.write({ hello: 'world' })
As a pino transport stream:
const graylogStream = require('graylog-stream')
const stream = graylogStream({ host: 'localhost', port: 12201 })
const pino = require('pino')({ stream })
pino.info('hello world')
In a pipeline:
import graylogStream from 'graylog-stream'
const stream = graylogStream({ host: 'localhost', port: 12201 })
process.stdin.pipe(stream)
In a pipeline with automatic cleanup:
import graylogStream from 'graylog-stream'
import { pipeline } from 'stream'
const stream = graylogStream({ host: 'localhost', port: 12201 })
pipeline(
process.stdin,
stream,
(err) => {
if (err) {
console.error(err)
process.exit(1)
}
}
)
As a worker_thread:
const { Worker } = require('worker_threads')
const worker = new Worker('./worker.js', { workerData: { host: 'localhost', port: 12201 } })
worker.postMessage({ hello: 'world' })