forked from pinojs/pino-gelf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
36 lines (29 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env node
'use strict';
const program = require('commander');
const version = require('./package.json').version;
const pinoGelf = require('./lib/pino-gelf');
program
.version(version);
program
.command('log')
.description('Run Pino-GELF')
.option('-h, --host [host]', 'Graylog Host')
.option('-p, --port [port]', 'Graylog Port', parseInt)
.option('-m, --max-chunk-size [maxChunkSize]', 'Graylog Input Maximum Chunk Size', parseInt)
.option('-v, --verbose', 'Output GELF to console')
.option('-t, --passthrough', 'Output original input to stdout to allow command chaining')
.action(function () {
const options = this.opts();
const opts = {
customKeys: options.specifyCustomFields || [],
host: options.host || '127.0.0.1',
maxChunkSize: options.maxChunkSize || 1420,
port: options.port || 12201,
verbose: (options.verbose && !options.passthrough) || false,
passthrough: options.passthrough || false
};
pinoGelf(opts);
});
program
.parse(process.argv);