diff --git a/README.md b/README.md index 30bdba2..449e263 100644 --- a/README.md +++ b/README.md @@ -70,17 +70,17 @@ node your-app.js | pino-gelf log -t __Note__: The defaults for these options are: -Property|Default ----|--- -Host|`127.0.0.1` -Port|`12201` -Protocol|`udp` -Maximum Chunk Size|`1420` -Keep Alive|`true` -Reconnection limit|`-1 (no limit)` -Reconnection delay|`1000` -Verbose Logging|`false` -Passthrough|`false` +Property|Environment Variable|Default +---|---|--- +Host|`PINO_GELF_HOST`|`127.0.0.1` +Port|`PINO_GELF_PORT`|`12201` +Protocol|`PINO_GELF_PROTOCOL`|`udp` +Maximum Chunk Size|`PINO_GELF_MAX_CHUNK_SIZE`|`1420` +Keep Alive|`PINO_GELF_KEEP_ALIVE` (note: any value set in an environment variable is interpreted as true)|`true` +Reconnection limit|`PINO_GELF_RECONNECTION_LIMIT`|`-1 (no limit)` +Reconnection delay|`PINO_GELF_RECONNECTION_DELAY`|`1000` +Verbose Logging|-|`false` +Passthrough|-|`false` ## Example diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 5288954..d7349a4 --- a/index.js +++ b/index.js @@ -12,15 +12,15 @@ program program .command('log') .description('Run Pino-GELF') - .option('-h, --host [host]', 'Graylog Host') - .option('-p, --port [port]', 'Graylog Port', parseInt) - .option('-P, --protocol [protocol]', 'Graylog protocol (UDP, HTTP, HTTPS, TCP, TLS)') - .option('-m, --max-chunk-size [maxChunkSize]', 'Graylog UDP Input Maximum Chunk Size', parseInt) - .option('-k, --keep-alive [keepAlive]', 'HTTP/TCP keep alive') - .option('-r, --reconnection-limit [reconnectionLimit]', 'TCP reconnection limit', parseInt) - .option('-d, --reconnection-delay [reconnectionDelay]', 'TCP reconnection delay', parseInt) - .option('-v, --verbose', 'Output GELF to console') - .option('-t, --passthrough', 'Output original input to stdout to allow command chaining') + .addOption(new program.Option('-h, --host [host]', 'Graylog Host').env('PINO_GELF_HOST')) + .addOption(new program.Option('-p, --port [port]', 'Graylog Port').env('PINO_GELF_PORT').argParser(parseInt)) + .addOption(new program.Option('-P, --protocol [protocol]', 'Graylog protocol (UDP, HTTP, HTTPS, TCP, TLS)').env('PINO_GELF_PROTOCOL')) + .addOption(new program.Option('-m, --max-chunk-size [maxChunkSize]', 'Graylog UDP Input Maximum Chunk Size').env('PINO_GELF_MAX_CHUNK_SIZE').argParser(parseInt)) + .addOption(new program.Option('-k, --keep-alive [keepAlive]', 'HTTP/TCP keep alive').env('PINO_GELF_KEEP_ALIVE')) + .addOption(new program.Option('-r, --reconnection-limit [reconnectionLimit]', 'TCP reconnection limit').env('PINO_GELF_RECONNECTION_LIMIT').argParser(parseInt)) + .addOption(new program.Option('-d, --reconnection-delay [reconnectionDelay]', 'TCP reconnection delay').env('PINO_GELF_RECONNECTION_DELAY').argParser(parseInt)) + .addOption(new program.Option('-v, --verbose', 'Output GELF to console')) + .addOption(new program.Option('-t, --passthrough', 'Output original input to stdout to allow command chaining')) .action(function () { const options = this.opts();