public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pavel Stehule <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: PoC - psql - emphases line with table name in verbose output
Date: Sun, 29 Mar 2026 18:42:46 +0200
Message-ID: <CAFj8pRD2MOak45s8=bex3BcncJf2jt9ukx=i9pKmWB1SepZu6g@mail.gmail.com> (raw)

Hi

Sometimes I have to run vacuum verbose in environments with hundreds of
tables. The result is pretty unreadable. Attached patch try introduce some
emphasis of interesting lines from INFO output. It is proof concept if some
game with output has some benefits or not.

What do you think about this?

Regards

Pavel


Attachments:

  [text/x-patch] 0001-initial.patch (2.0K, 3-0001-initial.patch)
  download | inline diff:
From abc37216aecb9b0201a8fa88d642d4e3cfd30432 Mon Sep 17 00:00:00 2001
From: "[email protected]" <[email protected]>
Date: Sun, 29 Mar 2026 18:01:16 +0200
Subject: [PATCH] initial

---
 src/common/logging.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/common/logging.c b/src/common/logging.c
index 5206949e5d8..c6229940f4f 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -30,11 +30,13 @@ static const char *sgr_error = NULL;
 static const char *sgr_warning = NULL;
 static const char *sgr_note = NULL;
 static const char *sgr_locus = NULL;
+static const char *sgr_info_command = NULL;
 
 #define SGR_ERROR_DEFAULT "01;31"
 #define SGR_WARNING_DEFAULT "01;35"
 #define SGR_NOTE_DEFAULT "01;36"
 #define SGR_LOCUS_DEFAULT "01"
+#define SGR_INFO_COMMAND_DEFAULT "07"
 
 #define ANSI_ESCAPE_FMT "\x1b[%sm"
 #define ANSI_ESCAPE_RESET "\x1b[0m"
@@ -143,6 +145,8 @@ pg_logging_init(const char *argv0)
 							sgr_note = strdup(value);
 						if (strcmp(name, "locus") == 0)
 							sgr_locus = strdup(value);
+						if (strcmp(name, "info_command") == 0)
+							sgr_info_command = strdup(value);
 					}
 				}
 
@@ -155,6 +159,7 @@ pg_logging_init(const char *argv0)
 			sgr_warning = SGR_WARNING_DEFAULT;
 			sgr_note = SGR_NOTE_DEFAULT;
 			sgr_locus = SGR_LOCUS_DEFAULT;
+			sgr_info_command = SGR_INFO_COMMAND_DEFAULT;
 		}
 	}
 }
@@ -331,7 +336,17 @@ pg_log_generic_v(enum pg_log_level level, enum pg_log_part part,
 	if (required_len >= 2 && buf[required_len - 2] == '\n')
 		buf[required_len - 2] = '\0';
 
-	fprintf(stderr, "%s\n", buf);
+	if (level == PG_LOG_INFO && sgr_info_command &&
+		(strncmp(buf, "INFO:  vacuuming", strlen("INFO:  vacuuming")) == 0 ||
+		 strncmp(buf, "INFO:  repacking", strlen("INFO:  vacuuming")) == 0 ||
+		 strncmp(buf, "INFO:  analyzing", strlen("INFO:  vacuuming")) == 0))
+	{
+		fprintf(stderr, ANSI_ESCAPE_FMT, sgr_info_command);
+		fprintf(stderr, "%s\n", buf);
+		fprintf(stderr, ANSI_ESCAPE_RESET);
+	}
+	else
+		fprintf(stderr, "%s\n", buf);
 
 	free(buf);
 }
-- 
2.53.0



view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: PoC - psql - emphases line with table name in verbose output
  In-Reply-To: <CAFj8pRD2MOak45s8=bex3BcncJf2jt9ukx=i9pKmWB1SepZu6g@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox