Skip to content

Commit faa25d3

Browse files
authored
cli options from env (#256)
1 parent ee14a60 commit faa25d3

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ node your-app.js | pino-gelf log -t
7070

7171
__Note__: The defaults for these options are:
7272

73-
Property|Default
74-
---|---
75-
Host|`127.0.0.1`
76-
Port|`12201`
77-
Protocol|`udp`
78-
Maximum Chunk Size|`1420`
79-
Keep Alive|`true`
80-
Reconnection limit|`-1 (no limit)`
81-
Reconnection delay|`1000`
82-
Verbose Logging|`false`
83-
Passthrough|`false`
73+
Property|Environment Variable|Default
74+
---|---|---
75+
Host|`PINO_GELF_HOST`|`127.0.0.1`
76+
Port|`PINO_GELF_PORT`|`12201`
77+
Protocol|`PINO_GELF_PROTOCOL`|`udp`
78+
Maximum Chunk Size|`PINO_GELF_MAX_CHUNK_SIZE`|`1420`
79+
Keep Alive|`PINO_GELF_KEEP_ALIVE`|`true`
80+
Reconnection limit|`PINO_GELF_RECONNECTION_LIMIT`|`-1 (no limit)`
81+
Reconnection delay|`PINO_GELF_RECONNECTION_DELAY`|`1000`
82+
Verbose Logging|-|`false`
83+
Passthrough|-|`false`
8484

8585

8686
## Example

index.js

100644100755
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ program
1212
program
1313
.command('log')
1414
.description('Run Pino-GELF')
15-
.option('-h, --host [host]', 'Graylog Host')
16-
.option('-p, --port [port]', 'Graylog Port', parseInt)
17-
.option('-P, --protocol [protocol]', 'Graylog protocol (UDP, HTTP, HTTPS, TCP, TLS)')
18-
.option('-m, --max-chunk-size [maxChunkSize]', 'Graylog UDP Input Maximum Chunk Size', parseInt)
19-
.option('-k, --keep-alive [keepAlive]', 'HTTP/TCP keep alive')
20-
.option('-r, --reconnection-limit [reconnectionLimit]', 'TCP reconnection limit', parseInt)
21-
.option('-d, --reconnection-delay [reconnectionDelay]', 'TCP reconnection delay', parseInt)
22-
.option('-v, --verbose', 'Output GELF to console')
23-
.option('-t, --passthrough', 'Output original input to stdout to allow command chaining')
15+
.addOption(new program.Option('-h, --host [host]', 'Graylog Host').env('PINO_GELF_HOST'))
16+
.addOption(new program.Option('-p, --port [port]', 'Graylog Port').env('PINO_GELF_PORT').argParser(parseInt))
17+
.addOption(new program.Option('-P, --protocol [protocol]', 'Graylog protocol (UDP, HTTP, HTTPS, TCP, TLS)').env('PINO_GELF_PROTOCOL'))
18+
.addOption(new program.Option('-m, --max-chunk-size [maxChunkSize]', 'Graylog UDP Input Maximum Chunk Size').env('PINO_GELF_MAX_CHUNK_SIZE').argParser(parseInt))
19+
.addOption(new program.Option('-k, --keep-alive [keepAlive]', 'HTTP/TCP keep alive').env('PINO_GELF_KEEP_ALIVE'))
20+
.addOption(new program.Option('-r, --reconnection-limit [reconnectionLimit]', 'TCP reconnection limit').env('PINO_GELF_RECONNECTION_LIMIT').argParser(parseInt))
21+
.addOption(new program.Option('-d, --reconnection-delay [reconnectionDelay]', 'TCP reconnection delay').env('PINO_GELF_RECONNECTION_DELAY').argParser(parseInt))
22+
.addOption(new program.Option('-v, --verbose', 'Output GELF to console'))
23+
.addOption(new program.Option('-t, --passthrough', 'Output original input to stdout to allow command chaining'))
2424
.action(function () {
2525
const options = this.opts();
2626

0 commit comments

Comments
 (0)