@@ -180,6 +180,7 @@ char *pghost = "";
180180char * pgport = "" ;
181181char * login = NULL ;
182182char * dbName ;
183+ char * logfile_prefix = NULL ;
183184const char * progname ;
184185
185186#define WSEP '@' /* weight separator */
@@ -511,6 +512,8 @@ usage(void)
511512 " --aggregate-interval=NUM aggregate data over NUM seconds\n"
512513 " --progress-timestamp use Unix epoch timestamps for progress\n"
513514 " --sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%%)\n"
515+ " --log-prefix=PREFIX prefix for transaction time log file\n"
516+ " (default: \"pgbench_log\")\n"
514517 "\nCommon options:\n"
515518 " -d, --debug print debugging output\n"
516519 " -h, --host=HOSTNAME database server host or socket directory\n"
@@ -3643,6 +3646,7 @@ main(int argc, char **argv)
36433646 {"sampling-rate" , required_argument , NULL , 4 },
36443647 {"aggregate-interval" , required_argument , NULL , 5 },
36453648 {"progress-timestamp" , no_argument , NULL , 6 },
3649+ {"log-prefix" , required_argument , NULL , 7 },
36463650 {NULL , 0 , NULL , 0 }
36473651 };
36483652
@@ -3990,6 +3994,10 @@ main(int argc, char **argv)
39903994 progress_timestamp = true;
39913995 benchmarking_option_set = true;
39923996 break ;
3997+ case 7 :
3998+ benchmarking_option_set = true;
3999+ logfile_prefix = pg_strdup (optarg );
4000+ break ;
39934001 default :
39944002 fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
39954003 exit (1 );
@@ -4087,6 +4095,12 @@ main(int argc, char **argv)
40874095 exit (1 );
40884096 }
40894097
4098+ if (!use_log && logfile_prefix )
4099+ {
4100+ fprintf (stderr , "log file prefix (--log-prefix) is allowed only when logging transactions (-l)\n" );
4101+ exit (1 );
4102+ }
4103+
40904104 if (duration > 0 && agg_interval > duration )
40914105 {
40924106 fprintf (stderr , "number of seconds for aggregation (%d) must not be higher than test duration (%d)\n" , agg_interval , duration );
@@ -4388,11 +4402,13 @@ threadRun(void *arg)
43884402 if (use_log )
43894403 {
43904404 char logpath [64 ];
4405+ char * prefix = logfile_prefix ? logfile_prefix : "pgbench_log" ;
43914406
43924407 if (thread -> tid == 0 )
4393- snprintf (logpath , sizeof (logpath ), "pgbench_log .%d" , main_pid );
4408+ snprintf (logpath , sizeof (logpath ), "%s .%d" , prefix , main_pid );
43944409 else
4395- snprintf (logpath , sizeof (logpath ), "pgbench_log.%d.%d" , main_pid , thread -> tid );
4410+ snprintf (logpath , sizeof (logpath ), "%s.%d.%d" , prefix , main_pid , thread -> tid );
4411+
43964412 thread -> logfile = fopen (logpath , "w" );
43974413
43984414 if (thread -> logfile == NULL )
0 commit comments