@@ -5,37 +5,28 @@ import build from './index'
5
5
import pkg from '../package.json'
6
6
import type { LokiOptions } from './types/index'
7
7
8
- /**
9
- * Parse cli arguments with commander
10
- */
11
- export const parseArgs = ( ) => {
12
- program
13
- . version ( pkg . version )
14
- . option ( '-u, --user <user>' , 'Loki username' )
15
- . option ( '-p, --password <password>' , 'Loki password' )
16
- . option ( '--hostname <hostname>' , 'URL for Loki' )
17
- . option ( '-b, --batch' , 'Should logs be sent in batch mode' )
18
- . option ( '-i, --interval <interval>' , 'The interval at which batched logs are sent in seconds' )
19
- . option ( '-t, --timeout <timeout>' , 'Timeout for request to Loki' )
20
- . option ( '-s, --silenceErrors' , 'If false, errors will be displayed in the console' )
21
- . option ( '-r, --replaceTimestamp' , 'Replace pino logs timestamps with Date.now()' )
22
- . option ( '-l, --labels <label>' , 'Additional labels to be added to all Loki logs' )
23
- . option (
24
- '-pl, --propsLabels <labels>' ,
25
- 'Fields in log line to convert to Loki labels (comma separated values)' ,
26
- )
27
- . option ( '--no-stdout' , 'Disable output to stdout' )
28
-
29
- program . parse ( process . argv )
30
-
31
- return program . opts ( )
32
- }
8
+ program
9
+ . version ( pkg . version )
10
+ . option ( '-u, --user <user>' , 'Loki username' )
11
+ . option ( '-p, --password <password>' , 'Loki password' )
12
+ . option ( '--hostname <hostname>' , 'URL for Loki' )
13
+ . option ( '-b, --batch' , 'Should logs be sent in batch mode' )
14
+ . option ( '-i, --interval <interval>' , 'The interval at which batched logs are sent in seconds' )
15
+ . option ( '-t, --timeout <timeout>' , 'Timeout for request to Loki' )
16
+ . option ( '-s, --silenceErrors' , 'If false, errors will be displayed in the console' )
17
+ . option ( '-r, --replaceTimestamp' , 'Replace pino logs timestamps with Date.now()' )
18
+ . option ( '-l, --labels <label>' , 'Additional labels to be added to all Loki logs' )
19
+ . option (
20
+ '-pl, --propsLabels <labels>' ,
21
+ 'Fields in log line to convert to Loki labels (comma separated values)' ,
22
+ )
23
+ . option ( '--no-stdout' , 'Disable output to stdout' )
33
24
34
25
/**
35
26
* Create a PinoLokiOptionsContract from cli arguments
36
27
*/
37
28
export const createPinoLokiConfigFromArgs = ( ) => {
38
- const opts = parseArgs ( )
29
+ const opts = program . parse ( process . argv ) . opts ( )
39
30
40
31
const config : LokiOptions = {
41
32
host : opts . hostname ,
0 commit comments