@@ -34,6 +34,9 @@ struct config_data cfg = {
34
34
.runtime_us = DEFAULT_RUNTIME ,
35
35
.pidfile_fd = -1 ,
36
36
.ev_backend = EVFLAG_AUTO ,
37
+ #ifdef LIBCURL
38
+ .access_log_mode = 3 ,
39
+ #endif
37
40
};
38
41
struct program_data prg ;
39
42
@@ -71,6 +74,9 @@ static void usage(const char *program_name, bool_t flag_verbose)
71
74
(void )printf (" -F, --pidfile=FILE Specifies a file to write the process-id to.\n" );
72
75
(void )printf (" -h, --help Show this text.\n" );
73
76
(void )printf (" -i, --monitor-interval=TIME Set the monitor interval (default: %s).\n" , str_delay (DEFAULT_MONITOR_INTERVAL ));
77
+ #ifdef HAVE_LIBCURL
78
+ (void )printf (" -L, --access-log=MODE Specify the mode of access logging (default: \"ALL\").\n" );
79
+ #endif
74
80
(void )printf (" -l, --logfile=[MODE:]FILE Log all messages to logfile (default: stdout/stderr).\n" );
75
81
(void )printf (" -m, --max-frame-size=VALUE Specify the maximum frame size (default: %d bytes).\n" , DEFAULT_MAX_FRAME_SIZE );
76
82
(void )printf (" -n, --num-workers=VALUE Specify the number of workers (default: %d).\n" , DEFAULT_NUM_WORKERS );
@@ -91,6 +97,7 @@ static void usage(const char *program_name, bool_t flag_verbose)
91
97
(void )printf ("for the mode, then line buffering is used when writing to the log file.\n\n" );
92
98
(void )printf ("The time delay/interval is specified in milliseconds by default, but can be\n" );
93
99
(void )printf ("in any other unit if the number is suffixed by a unit (us, ms, s, m, h, d).\n\n" );
100
+ (void )printf ("Access logging modes are 'NONE', 'ERROR', 'SUCCESS', 'ALL'.\n\n" );
94
101
(void )printf ("Copyright 2018-2020 HAProxy Technologies\n" );
95
102
(void )printf ("SPDX-License-Identifier: GPL-2.0-or-later\n\n" );
96
103
} else {
@@ -326,6 +333,55 @@ static int getopt_set_ports(const char *ports, int *range)
326
333
}
327
334
328
335
336
+ /***
337
+ * NAME
338
+ * getopt_set_access_log_mode -
339
+ *
340
+ * ARGUMENTS
341
+ * mode_txt -
342
+ * mode_val -
343
+ *
344
+ * DESCRIPTION
345
+ * -
346
+ *
347
+ * RETURN VALUE
348
+ * -
349
+ */
350
+ static int getopt_set_access_log_mode (const char * mode_txt , int * mode_val )
351
+ {
352
+ int retval = FUNC_RET_ERROR , mode = 0 ;
353
+
354
+ DBG_FUNC (NULL , "\"%s\", %p" , mode_txt , mode_val );
355
+
356
+ if (* mode_txt == 'A' || * mode_txt == 'a' ) {
357
+ mode = 3 ;
358
+ retval = FUNC_RET_OK ;
359
+ }
360
+ else if (* mode_txt == 'E' || * mode_txt == 'e' ) {
361
+ mode = 2 ;
362
+ retval = FUNC_RET_OK ;
363
+ }
364
+ else if (* mode_txt == 'S' || * mode_txt == 's' ) {
365
+ mode = 1 ;
366
+ retval = FUNC_RET_OK ;
367
+ }
368
+ else if (* mode_txt == 'N' || * mode_txt == 'n' ) {
369
+ mode = 0 ;
370
+ retval = FUNC_RET_OK ;
371
+ }
372
+ else
373
+ (void )fprintf (stderr , "ERROR: access log mode must be one of 'ALL', 'ERROR', 'SUCCESS', or 'NONE'\n" );
374
+
375
+ /* If everything is fine, set the mode. */
376
+ if (_OK (retval )) {
377
+ * mode_val = mode ;
378
+ W_DBG (NOTICE , NULL , " mode set to %d" , mode );
379
+ }
380
+
381
+ return retval ;
382
+ }
383
+
384
+
329
385
/***
330
386
* NAME
331
387
* main -
@@ -360,6 +416,7 @@ int main(int argc, char **argv, char **envp __maybe_unused)
360
416
{ "runtime" , required_argument , NULL , 'r' },
361
417
{ "processing-delay" , required_argument , NULL , 't' },
362
418
#ifdef HAVE_LIBCURL
419
+ { "access-log" , required_argument , NULL , 'L' },
363
420
{ "mirror-url" , required_argument , NULL , 'u' },
364
421
{ "mirror-interface" , required_argument , NULL , 'I' },
365
422
{ "mirror-local-port" , required_argument , NULL , 'P' },
@@ -422,6 +479,8 @@ int main(int argc, char **argv, char **envp __maybe_unused)
422
479
else if (c == 't' )
423
480
flag_error |= _OK (getopt_set_time (optarg , & (cfg .processing_delay_us ), 0 , TIMEINT_S (1 ))) ? 0 : 1 ;
424
481
#ifdef HAVE_LIBCURL
482
+ else if (c == 'L')
483
+ flag_error |= _OK (getopt_set_access_log_mode (optarg , & (cfg .access_log_mode ))) ? 0 : 1 ;
425
484
else if (c == 'u')
426
485
mir_url = optarg ;
427
486
else if (c == 'I ')
0 commit comments