Skip to content

Commit b69873a

Browse files
Merge pull request #6546 from oliver-sanders/log-rollover-time
logging: update header timestamp on rollover
2 parents 0d204cc + a280308 commit b69873a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: cylc/flow/loggingutil.py

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import re
3232
import sys
3333
import textwrap
34+
from time import time
3435
from typing import List, Optional, Union
3536

3637
from ansimarkup import parse as cparse, strip as cstrip
@@ -238,15 +239,22 @@ def do_rollover(self) -> None:
238239
os.dup2(self.stream.fileno(), sys.stderr.fileno())
239240
# Emit header records (should only do this for subsequent log files)
240241
for header_record in self.header_records:
242+
now = time()
241243
if self.ROLLOVER_NUM in header_record.__dict__:
242244
# A hack to increment the rollover number that gets logged in
243245
# the log file. (Rollover number only applies to a particular
244246
# workflow run; note this is different from the log count
245247
# number in the log filename.)
248+
246249
header_record.__dict__[self.ROLLOVER_NUM] += 1
247250
header_record.args = (
248251
header_record.__dict__[self.ROLLOVER_NUM],
249252
)
253+
254+
# patch the record time (otherwise this will be logged with the
255+
# original timestamp)
256+
header_record.created = now
257+
250258
logging.FileHandler.emit(self, header_record)
251259

252260
def update_log_archive(self, arch_len: int) -> None:

0 commit comments

Comments
 (0)