0001-logging-Also-add-the-command-prefix-to-detail-and-hi.patch

text/plain

Filename: 0001-logging-Also-add-the-command-prefix-to-detail-and-hi.patch
Type: text/plain
Part: 0
Message: Re: Frontend error logging style

Patch

Format: format-patch
Series: patch 0001
Subject: logging: Also add the command prefix to detail and hint messages
File+
src/bin/pg_dump/t/003_pg_dump_with_server.pl 1 1
src/common/logging.c 1 2
From 565fe56ebf9449cd9143424ef1b8083d99019d75 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 23 May 2022 11:44:32 +0200
Subject: [PATCH] logging: Also add the command prefix to detail and hint
 messages

This makes the output line up better and allows filtering messages by
command.
---
 src/bin/pg_dump/t/003_pg_dump_with_server.pl | 2 +-
 src/common/logging.c                         | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/bin/pg_dump/t/003_pg_dump_with_server.pl b/src/bin/pg_dump/t/003_pg_dump_with_server.pl
index a0b23aae0f..8cc9da0659 100644
--- a/src/bin/pg_dump/t/003_pg_dump_with_server.pl
+++ b/src/bin/pg_dump/t/003_pg_dump_with_server.pl
@@ -30,7 +30,7 @@
 
 command_fails_like(
 	[ "pg_dump", '-p', $port, '--include-foreign-data=s0', 'postgres' ],
-	qr/foreign-data wrapper \"dummy\" has no handler\r?\ndetail: Query was: .*t0/,
+	qr/foreign-data wrapper \"dummy\" has no handler\r?\npg_dump: detail: Query was: .*t0/,
 	"correctly fails to dump a foreign table from a dummy FDW");
 
 command_ok(
diff --git a/src/common/logging.c b/src/common/logging.c
index 0b5bcb1a17..64604c5209 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -246,8 +246,7 @@ pg_log_generic_v(enum pg_log_level level, enum pg_log_part part,
 
 	fmt = _(fmt);
 
-	if (part == PG_LOG_PRIMARY &&
-		(!(log_flags & PG_LOG_FLAG_TERSE) || filename))
+	if (!(log_flags & PG_LOG_FLAG_TERSE) || filename)
 	{
 		if (sgr_locus)
 			fprintf(stderr, ANSI_ESCAPE_FMT, sgr_locus);
-- 
2.36.1