Skip to content

Commit 3da060c

Browse files
author
Commitfest Bot
committed
[CF 5365] v1 - Fix creation of empty .log files during log rotation
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5365 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/[email protected] Author(s): Arseny Kositsin
2 parents d6d8054 + 6cfb3f7 commit 3da060c

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)