From abc37216aecb9b0201a8fa88d642d4e3cfd30432 Mon Sep 17 00:00:00 2001
From: "okbob@github.com" <pavel.stehule@gmail.com>
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

