diff options
author | Magnus Hagander <magnus@hagander.net> | 2013-01-17 14:38:49 +0100 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2013-01-17 14:38:49 +0100 |
commit | d7e9ca7ff7efac8b15d4348fd9480c12ed560ae7 (patch) | |
tree | 3bd4bd3f5f720d85cfb2ce1f935f24a78df87d25 /src | |
parent | f3af53441ed0b306692a1cc31003a84d1b5b3cf7 (diff) | |
download | postgresql-d7e9ca7ff7efac8b15d4348fd9480c12ed560ae7.tar.gz postgresql-d7e9ca7ff7efac8b15d4348fd9480c12ed560ae7.zip |
Truncate filenames in the leadning end in pg_basebackup verbose output
When truncating at the end, like before, the output would often end up
just showing the path instead of the filename.
Also increase the length of the filename by 5, which still keeps us at
less than 80 characters in most outputs.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index ffc882616fc..36f825e95c8 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -422,6 +422,7 @@ progress_report(int tablespacenum, const char *filename) totaldone / 1024); snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize); +#define VERBOSE_FILENAME_LENGTH 35 if (verbose) { if (!filename) @@ -431,18 +432,29 @@ progress_report(int tablespacenum, const char *filename) * call) */ fprintf(stderr, - ngettext("%s/%s kB (100%%), %d/%d tablespace %35s", - "%s/%s kB (100%%), %d/%d tablespaces %35s", + ngettext("%s/%s kB (100%%), %d/%d tablespace %*s", + "%s/%s kB (100%%), %d/%d tablespaces %*s", tablespacecount), totaldone_str, totalsize_str, - tablespacenum, tablespacecount, ""); + tablespacenum, tablespacecount, + VERBOSE_FILENAME_LENGTH + 5, ""); else + { + bool truncate = (strlen(filename) > VERBOSE_FILENAME_LENGTH); + fprintf(stderr, - ngettext("%s/%s kB (%d%%), %d/%d tablespace (%-30.30s)", - "%s/%s kB (%d%%), %d/%d tablespaces (%-30.30s)", + ngettext("%s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)", + "%s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)", tablespacecount), totaldone_str, totalsize_str, percent, - tablespacenum, tablespacecount, filename); + tablespacenum, tablespacecount, + /* Prefix with "..." if we do leading truncation */ + truncate ? "..." : "", + truncate ? VERBOSE_FILENAME_LENGTH - 3 : VERBOSE_FILENAME_LENGTH, + truncate ? VERBOSE_FILENAME_LENGTH - 3 : VERBOSE_FILENAME_LENGTH, + /* Truncate filename at beginning if it's too long */ + truncate ? filename + strlen(filename) - VERBOSE_FILENAME_LENGTH + 3 : filename); + } } else fprintf(stderr, |