Skip to content

Commit

Permalink
Merge pull request #6546 from oliver-sanders/log-rollover-time
Browse files Browse the repository at this point in the history
logging: update header timestamp on rollover
  • Loading branch information
oliver-sanders authored Jan 16, 2025
2 parents 0d204cc + a280308 commit b69873a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cylc/flow/loggingutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import re
import sys
import textwrap
from time import time
from typing import List, Optional, Union

from ansimarkup import parse as cparse, strip as cstrip
Expand Down Expand Up @@ -238,15 +239,22 @@ def do_rollover(self) -> None:
os.dup2(self.stream.fileno(), sys.stderr.fileno())
# Emit header records (should only do this for subsequent log files)
for header_record in self.header_records:
now = time()
if self.ROLLOVER_NUM in header_record.__dict__:
# A hack to increment the rollover number that gets logged in
# the log file. (Rollover number only applies to a particular
# workflow run; note this is different from the log count
# number in the log filename.)

header_record.__dict__[self.ROLLOVER_NUM] += 1
header_record.args = (
header_record.__dict__[self.ROLLOVER_NUM],
)

# patch the record time (otherwise this will be logged with the
# original timestamp)
header_record.created = now

logging.FileHandler.emit(self, header_record)

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

0 comments on commit b69873a

Please sign in to comment.