@@ -180,6 +180,7 @@ char *pghost = "";
180
180
char * pgport = "" ;
181
181
char * login = NULL ;
182
182
char * dbName ;
183
+ char * logfile_prefix = NULL ;
183
184
const char * progname ;
184
185
185
186
#define WSEP '@' /* weight separator */
@@ -511,6 +512,8 @@ usage(void)
511
512
" --aggregate-interval=NUM aggregate data over NUM seconds\n"
512
513
" --progress-timestamp use Unix epoch timestamps for progress\n"
513
514
" --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"
514
517
"\nCommon options:\n"
515
518
" -d, --debug print debugging output\n"
516
519
" -h, --host=HOSTNAME database server host or socket directory\n"
@@ -3643,6 +3646,7 @@ main(int argc, char **argv)
3643
3646
{"sampling-rate" , required_argument , NULL , 4 },
3644
3647
{"aggregate-interval" , required_argument , NULL , 5 },
3645
3648
{"progress-timestamp" , no_argument , NULL , 6 },
3649
+ {"log-prefix" , required_argument , NULL , 7 },
3646
3650
{NULL , 0 , NULL , 0 }
3647
3651
};
3648
3652
@@ -3990,6 +3994,10 @@ main(int argc, char **argv)
3990
3994
progress_timestamp = true;
3991
3995
benchmarking_option_set = true;
3992
3996
break ;
3997
+ case 7 :
3998
+ benchmarking_option_set = true;
3999
+ logfile_prefix = pg_strdup (optarg );
4000
+ break ;
3993
4001
default :
3994
4002
fprintf (stderr , _ ("Try \"%s --help\" for more information.\n" ), progname );
3995
4003
exit (1 );
@@ -4087,6 +4095,12 @@ main(int argc, char **argv)
4087
4095
exit (1 );
4088
4096
}
4089
4097
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
+
4090
4104
if (duration > 0 && agg_interval > duration )
4091
4105
{
4092
4106
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)
4388
4402
if (use_log )
4389
4403
{
4390
4404
char logpath [64 ];
4405
+ char * prefix = logfile_prefix ? logfile_prefix : "pgbench_log" ;
4391
4406
4392
4407
if (thread -> tid == 0 )
4393
- snprintf (logpath , sizeof (logpath ), "pgbench_log .%d" , main_pid );
4408
+ snprintf (logpath , sizeof (logpath ), "%s .%d" , prefix , main_pid );
4394
4409
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
+
4396
4412
thread -> logfile = fopen (logpath , "w" );
4397
4413
4398
4414
if (thread -> logfile == NULL )
0 commit comments