Skip to content

Commit 6cfb3f7

Browse files
arseny114Commitfest Bot
authored and
Commitfest Bot
committed
Fixed creation of an empty .log file
When logs are rotated, if the log_destination = 'csvlog', besides .csv file, an empty .log file was created. In order to correct this behavior, an additional check has been added to the log file_rotate() function.
1 parent d6d8054 commit 6cfb3f7

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/backend/postmaster/syslogger.c

+15-12
Original file line numberDiff line numberDiff line change
@@ -1377,22 +1377,25 @@ logfile_rotate(bool time_based_rotation, int size_rotation_for)
13771377
fntime = time(NULL);
13781378

13791379
/* file rotation for stderr */
1380-
if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime,
1381-
LOG_DESTINATION_STDERR, &last_sys_file_name,
1382-
&syslogFile))
1383-
return;
1380+
if ((Log_destination & LOG_DESTINATION_STDERR) != 0)
1381+
if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime,
1382+
LOG_DESTINATION_STDERR, &last_sys_file_name,
1383+
&syslogFile))
1384+
return;
13841385

13851386
/* file rotation for csvlog */
1386-
if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime,
1387-
LOG_DESTINATION_CSVLOG, &last_csv_file_name,
1388-
&csvlogFile))
1389-
return;
1387+
if ((Log_destination & LOG_DESTINATION_CSVLOG) != 0)
1388+
if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime,
1389+
LOG_DESTINATION_CSVLOG, &last_csv_file_name,
1390+
&csvlogFile))
1391+
return;
13901392

13911393
/* file rotation for jsonlog */
1392-
if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime,
1393-
LOG_DESTINATION_JSONLOG, &last_json_file_name,
1394-
&jsonlogFile))
1395-
return;
1394+
if ((Log_destination & LOG_DESTINATION_JSONLOG) != 0)
1395+
if (!logfile_rotate_dest(time_based_rotation, size_rotation_for, fntime,
1396+
LOG_DESTINATION_JSONLOG, &last_json_file_name,
1397+
&jsonlogFile))
1398+
return;
13961399

13971400
update_metainfo_datafile();
13981401

0 commit comments

Comments
 (0)