@@ -177,6 +177,9 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
177177 * There is no need to lock if this is elog() from upper elog().
178178 */
179179#ifdef WIN32
180+ std_args = NULL ;
181+ error_args = NULL ;
182+
180183 if (log_file_mutex == NULL )
181184 {
182185 while (InterlockedExchange (& mutex_initlock , 1 ) == 1 )
@@ -190,14 +193,14 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
190193 loggin_in_progress = true;
191194
192195 /* We need copy args only if we need write to error log file */
193- // if (write_to_error_log)
194- // va_copy(error_args, args);
196+ if (write_to_error_log )
197+ va_copy (error_args , args );
195198 /*
196199 * We need copy args only if we need write to stderr. But do not copy args
197200 * if we need to log only to stderr.
198201 */
199- // if (write_to_stderr && write_to_file)
200- // va_copy(std_args, args);
202+ if (write_to_stderr && write_to_file )
203+ va_copy (std_args , args );
201204
202205 if (write_to_file || write_to_error_log )
203206 strftime (strfbuf , sizeof (strfbuf ), "%Y-%m-%d %H:%M:%S %Z" ,
@@ -239,7 +242,6 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
239242 fprintf (error_log_file , "%s: " , strfbuf );
240243 write_elevel (error_log_file , elevel );
241244
242- va_copy (error_args , args );
243245 vfprintf (error_log_file , fmt , error_args );
244246 fputc ('\n' , error_log_file );
245247 fflush (error_log_file );
@@ -254,7 +256,6 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
254256 if (write_to_stderr )
255257 {
256258 write_elevel (stderr , elevel );
257- va_copy (std_args , args );
258259 if (write_to_file )
259260 vfprintf (stderr , fmt , std_args );
260261 else
0 commit comments