From cad3edef4f51c37c4b4d8667a2e76a81ca53f9e7 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Mon, 28 Mar 2016 14:33:00 -0300
Subject: [PATCH] pg_rewind: Improve internationalization
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is mostly cosmetic since two of the three changes are debug
messages, and the third one is just a progress indicator.

Author: Michaël Paquier
---
 src/bin/pg_rewind/datapagemap.c |  3 ++-
 src/bin/pg_rewind/filemap.c     |  6 +++++-
 src/bin/pg_rewind/pg_rewind.c   | 12 +++++++-----
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/bin/pg_rewind/datapagemap.c b/src/bin/pg_rewind/datapagemap.c
index 011693faa44..a79b4275274 100644
--- a/src/bin/pg_rewind/datapagemap.c
+++ b/src/bin/pg_rewind/datapagemap.c
@@ -13,6 +13,7 @@
 #include "postgres_fe.h"
 
 #include "datapagemap.h"
+#include "logging.h"
 
 struct datapagemap_iterator
 {
@@ -120,7 +121,7 @@ datapagemap_print(datapagemap_t *map)
 
 	iter = datapagemap_iterate(map);
 	while (datapagemap_next(iter, &blocknum))
-		printf("  blk %u\n", blocknum);
+		pg_log(PG_DEBUG, "  block %u\n", blocknum);
 
 	pg_free(iter);
 }
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index 895deb1e13a..a3e52f6f2a7 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -531,7 +531,11 @@ print_filemap(void)
 		if (entry->action != FILE_ACTION_NONE ||
 			entry->pagemap.bitmapsize > 0)
 		{
-			printf("%s (%s)\n", entry->path, action_to_str(entry->action));
+			pg_log(PG_DEBUG,
+			/*------
+			   translator: first %s is a file path, second is a keyword such as COPY */
+				   "%s (%s)\n", entry->path,
+				   action_to_str(entry->action));
 
 			if (entry->pagemap.bitmapsize > 0)
 				datapagemap_print(&entry->pagemap);
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 4c80000ceae..4004bbfc774 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -470,9 +470,9 @@ getTimelineHistory(ControlFileData *controlFile, int *nentries)
 		int		i;
 
 		if (controlFile == &ControlFile_source)
-			printf("Source timeline history:\n");
+			pg_log(PG_DEBUG, "Source timeline history:\n");
 		else if (controlFile == &ControlFile_target)
-			printf("Target timeline history:\n");
+			pg_log(PG_DEBUG, "Target timeline history:\n");
 		else
 			Assert(false);
 
@@ -484,9 +484,11 @@ getTimelineHistory(ControlFileData *controlFile, int *nentries)
 			TimeLineHistoryEntry *entry;
 
 			entry = &history[i];
-			printf("%d: %X/%X - %X/%X\n", entry->tli,
-				(uint32) (entry->begin >> 32), (uint32) (entry->begin),
-				(uint32) (entry->end >> 32), (uint32) (entry->end));
+			pg_log(PG_DEBUG,
+			/* translator: %d is a timeline number, others are LSN positions */
+				   "%d: %X/%X - %X/%X\n", entry->tli,
+				   (uint32) (entry->begin >> 32), (uint32) (entry->begin),
+				   (uint32) (entry->end >> 32), (uint32) (entry->end));
 		}
 	}
 
-- 
GitLab