Make size-output fixed length in pg_basebackup verbose mode

This way the line doesn't shift right as the amount of data processed
increases.
This commit is contained in:
Magnus Hagander 2013-01-17 14:43:33 +01:00
parent d7e9ca7ff7
commit 4eebf1309f

View File

@ -432,9 +432,10 @@ progress_report(int tablespacenum, const char *filename)
* call) * call)
*/ */
fprintf(stderr, fprintf(stderr,
ngettext("%s/%s kB (100%%), %d/%d tablespace %*s", ngettext("%*s/%s kB (100%%), %d/%d tablespace %*s",
"%s/%s kB (100%%), %d/%d tablespaces %*s", "%*s/%s kB (100%%), %d/%d tablespaces %*s",
tablespacecount), tablespacecount),
strlen(totalsize_str),
totaldone_str, totalsize_str, totaldone_str, totalsize_str,
tablespacenum, tablespacecount, tablespacenum, tablespacecount,
VERBOSE_FILENAME_LENGTH + 5, ""); VERBOSE_FILENAME_LENGTH + 5, "");
@ -443,9 +444,10 @@ progress_report(int tablespacenum, const char *filename)
bool truncate = (strlen(filename) > VERBOSE_FILENAME_LENGTH); bool truncate = (strlen(filename) > VERBOSE_FILENAME_LENGTH);
fprintf(stderr, fprintf(stderr,
ngettext("%s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)", ngettext("%*s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)",
"%s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)", "%*s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)",
tablespacecount), tablespacecount),
strlen(totalsize_str),
totaldone_str, totalsize_str, percent, totaldone_str, totalsize_str, percent,
tablespacenum, tablespacecount, tablespacenum, tablespacecount,
/* Prefix with "..." if we do leading truncation */ /* Prefix with "..." if we do leading truncation */
@ -458,9 +460,10 @@ progress_report(int tablespacenum, const char *filename)
} }
else else
fprintf(stderr, fprintf(stderr,
ngettext("%s/%s kB (%d%%), %d/%d tablespace", ngettext("%*s/%s kB (%d%%), %d/%d tablespace",
"%s/%s kB (%d%%), %d/%d tablespaces", "%*s/%s kB (%d%%), %d/%d tablespaces",
tablespacecount), tablespacecount),
strlen(totalsize_str),
totaldone_str, totalsize_str, percent, totaldone_str, totalsize_str, percent,
tablespacenum, tablespacecount); tablespacenum, tablespacecount);