Skip to content

Commit d6ee6b1

Browse files
committed
Fix copying args to std_args
1 parent 2b02bd4 commit d6ee6b1

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

configure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* configure.c: - manage backup catalog.
44
*
5-
* Portions Copyright (c) 2017-2017, Postgres Professional
5+
* Copyright (c) 2017-2017, Postgres Professional
66
*
77
*-------------------------------------------------------------------------
88
*/

help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* help.c
44
*
5-
* Portions Copyright (c) 2017-2017, Postgres Professional
5+
* Copyright (c) 2017-2017, Postgres Professional
66
*
77
*-------------------------------------------------------------------------
88
*/

utils/logger.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ static void
105105
elog_internal(int elevel, const char *fmt, va_list args)
106106
{
107107
bool wrote_to_file = false,
108-
write_to_error_log,
109-
write_to_stderr;
108+
write_to_error_log;
110109
va_list error_args,
111110
std_args;
112111

@@ -119,6 +118,9 @@ elog_internal(int elevel, const char *fmt, va_list args)
119118
/* We need copy args only if we need write to error log file */
120119
if (write_to_error_log)
121120
va_copy(error_args, args);
121+
/* We need copy args only if we need write to stderr */
122+
if (elevel >= ERROR || !(log_filename && !logging_to_file))
123+
va_copy(std_args, args);
122124

123125
/*
124126
* Write message to log file.
@@ -142,15 +144,6 @@ elog_internal(int elevel, const char *fmt, va_list args)
142144
wrote_to_file = true;
143145
}
144146

145-
/*
146-
* Write to stderr if the message was not written to log file.
147-
* Write to stderr if the message level is greater than WARNING anyway.
148-
*/
149-
write_to_stderr = !wrote_to_file || elevel >= ERROR;
150-
/* We need copy args only if we need write to stderr */
151-
if (write_to_stderr)
152-
va_copy(std_args, error_args);
153-
154147
/*
155148
* Write error message to error log file.
156149
* Do not write to file if this error was raised during write previous
@@ -173,7 +166,11 @@ elog_internal(int elevel, const char *fmt, va_list args)
173166
va_end(error_args);
174167
}
175168

176-
if (write_to_stderr)
169+
/*
170+
* Write to stderr if the message was not written to log file.
171+
* Write to stderr if the message level is greater than WARNING anyway.
172+
*/
173+
if (!wrote_to_file || elevel >= ERROR)
177174
{
178175
write_elevel(stderr, elevel);
179176

0 commit comments

Comments
 (0)