@@ -165,6 +165,7 @@ static void flb_help(int rc, struct flb_config *config)
165165 print_opt ("-q, --quiet" , "quiet mode" );
166166 print_opt ("-S, --sosreport" , "support report for Enterprise customers" );
167167 print_opt ("-Y, --enable-hot-reload" , "enable for hot reloading" );
168+ print_opt ("-a, --dump-config" , "print configuration on startup" );
168169 print_opt ("-W, --disable-thread-safety-on-hot-reloading" , "disable thread safety on hot reloading" );
169170 print_opt ("-V, --version" , "show version number" );
170171 print_opt ("-h, --help" , "print this help" );
@@ -948,13 +949,17 @@ int flb_main(int argc, char **argv)
948949 int opt ;
949950 int ret ;
950951 flb_sds_t json ;
952+ int dump_cfg ;
951953
952954 /* handle plugin properties: -1 = none, 0 = input, 1 = output */
953955 int last_plugin = -1 ;
954956
955957 /* local variables to handle config options */
956958 char * cfg_file = NULL ;
957959
960+ /* do not dump config file on default */
961+ dump_cfg = FLB_FALSE ;
962+
958963 /* config format context */
959964 struct flb_cf * cf ;
960965 struct flb_cf * tmp ;
@@ -1024,6 +1029,7 @@ int flb_main(int argc, char **argv)
10241029 { "http_listen" , required_argument , NULL , 'L' },
10251030 { "http_port" , required_argument , NULL , 'P' },
10261031#endif
1032+ { "dump-config" , no_argument , NULL , 'a' },
10271033 { "enable-hot-reload" , no_argument , NULL , 'Y' },
10281034#ifdef FLB_HAVE_CHUNK_TRACE
10291035 { "enable-chunk-trace" , no_argument , NULL , 'Z' },
@@ -1063,7 +1069,7 @@ int flb_main(int argc, char **argv)
10631069 /* Parse the command line options */
10641070 while ((opt = getopt_long (argc , argv ,
10651071 "b:c:dDf:C:i:m:o:R:F:p:e:"
1066- "t:T:l:vw:qVhJL:HP:s:SWYZ " ,
1072+ "t:T:l:vw:qVhJL:HP:s:SWaYZ " ,
10671073 long_opts , NULL )) != -1 ) {
10681074
10691075 switch (opt ) {
@@ -1221,6 +1227,9 @@ int flb_main(int argc, char **argv)
12211227 case 'Y' :
12221228 flb_cf_section_property_add (cf_opts , service -> properties , FLB_CONF_STR_HOT_RELOAD , 0 , "on" , 0 );
12231229 break ;
1230+ case 'a' :
1231+ dump_cfg = FLB_TRUE ;
1232+ break ;
12241233 case 'W' :
12251234 flb_cf_section_property_add (cf_opts , service -> properties ,
12261235 FLB_CONF_STR_HOT_RELOAD_ENSURE_THREAD_SAFETY , 0 , "off" , 0 );
@@ -1314,6 +1323,16 @@ int flb_main(int argc, char **argv)
13141323 cf = tmp ;
13151324#endif
13161325
1326+ /* Print read config for debugging purposes */
1327+ if (dump_cfg ) {
1328+ if (cf ) {
1329+ fprintf (stderr , "[debug] read configuration:\n" );
1330+ flb_cf_dump (cf );
1331+ fflush (stdout );
1332+ fflush (stderr );
1333+ }
1334+ }
1335+
13171336 /* Check co-routine stack size */
13181337 if (config -> coro_stack_size < getpagesize ()) {
13191338 flb_cf_destroy (cf_opts );
0 commit comments