Skip to content

Commit a432729

Browse files
committed
Set log_line_prefix and application name in test drivers
Before pg_regress runs psql, set the application name to the test name. Similarly, set the application name to the test file name in the TAP tests. Also, set a default log_line_prefix that show the application name, as well as the PID and a time stamp. That way, the server log output can be correlated to the test input files, making debugging a bit easier.
1 parent f002ed2 commit a432729

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/test/perl/PostgresNode.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ sub init
409409
open my $conf, ">>$pgdata/postgresql.conf";
410410
print $conf "\n# Added by PostgresNode.pm\n";
411411
print $conf "fsync = off\n";
412+
print $conf "log_line_prefix = '%m [%p] %q%a '\n";
412413
print $conf "log_statement = all\n";
413414
print $conf "port = $port\n";
414415

src/test/perl/TestLib.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ BEGIN
6262
delete $ENV{PGPORT};
6363
delete $ENV{PGHOST};
6464

65+
$ENV{PGAPPNAME} = $0;
66+
6567
# Must be set early
6668
$windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys';
6769
}

src/test/regress/pg_regress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
22702270
fputs("\n# Configuration added by pg_regress\n\n", pg_conf);
22712271
fputs("log_autovacuum_min_duration = 0\n", pg_conf);
22722272
fputs("log_checkpoints = on\n", pg_conf);
2273+
fputs("log_line_prefix = '%m [%p] %q%a '\n", pg_conf);
22732274
fputs("log_lock_waits = on\n", pg_conf);
22742275
fputs("log_temp_files = 128kB\n", pg_conf);
22752276
fputs("max_prepared_transactions = 2\n", pg_conf);

src/test/regress/pg_regress_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ psql_start_test(const char *testname,
3434
char expectfile[MAXPGPATH];
3535
char psql_cmd[MAXPGPATH * 3];
3636
size_t offset = 0;
37+
char *appnameenv;
3738

3839
/*
3940
* Look for files in the output dir first, consistent with a vpath search.
@@ -63,6 +64,9 @@ psql_start_test(const char *testname,
6364
offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
6465
"%s ", launcher);
6566

67+
appnameenv = psprintf("PGAPPNAME=pg_regress/%s", testname);
68+
putenv(appnameenv);
69+
6670
snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
6771
"\"%s%spsql\" -X -a -q -d \"%s\" < \"%s\" > \"%s\" 2>&1",
6872
bindir ? bindir : "",
@@ -80,6 +84,9 @@ psql_start_test(const char *testname,
8084
exit(2);
8185
}
8286

87+
unsetenv("PGAPPNAME");
88+
free(appnameenv);
89+
8390
return pid;
8491
}
8592

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy