From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Fujii Masao <fujii(at)postgresql(dot)org>, pgsql-committers <pgsql-committers(at)postgresql(dot)org> |
Subject: | Re: pgsql: Mark the second argument of pg_log as the translatable string in |
Date: | 2015-04-15 03:41:17 |
Message-ID: | CAHGQGwEgBEyXXrV6G=9ZhBOxypo06JrGQGBgwv+T-+PcjaWvfA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
On Tue, Apr 14, 2015 at 2:17 AM, Alvaro Herrera
<alvherre(at)2ndquadrant(dot)com> wrote:
> Michael Paquier wrote:
>> On Sun, Apr 12, 2015 at 10:17 AM, Alvaro Herrera wrote:
>> > What pg_basebackup's progress_report() does is have the message in the
>> > translatable part not include the \r; the \r is in a separate fprintf()
>> > call.
>>
>> Like the attached then.
>
> Not a fan of this approach, because now this function knows that
> pg_log(PG_PROGRESS) is equivalent to printf(). This abstraction is a
> bit leaky, isn't it ... Probably not worth sweating about, though.
>
>> diff --git a/src/bin/pg_rewind/logging.c b/src/bin/pg_rewind/logging.c
>> index aba12d8..3e2dc76 100644
>> --- a/src/bin/pg_rewind/logging.c
>> +++ b/src/bin/pg_rewind/logging.c
>> @@ -134,7 +134,8 @@ progress_report(bool force)
>> snprintf(fetch_size_str, sizeof(fetch_size_str), INT64_FORMAT,
>> fetch_size / 1024);
>>
>> - pg_log(PG_PROGRESS, "%*s/%s kB (%d%%) copied\r",
>> + pg_log(PG_PROGRESS, "%*s/%s kB (%d%%) copied",
>> (int) strlen(fetch_size_str), fetch_done_str, fetch_size_str,
>> percent);
>> + printf("\r");
>> }
So could you elaborate your "favorite" approach?
Now pg_log() calls printf() and fflush(stdout). So '\r' is printed after fflush.
It's a bit strange. Maybe we can just replace pg_log() with printf() here.
Another question is; should we output the progress report to stderr rather
than stdout? I thought this because I found that pg_basebackup reports
the progress to stderr.
Regards,
--
Fujii Masao
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2015-04-15 07:55:49 | Re: pgsql: Mark the second argument of pg_log as the translatable string in |
Previous Message | Peter Eisentraut | 2015-04-15 00:32:12 | pgsql: Integrate pg_upgrade_support module into backend |