Skip to content

Commit

Permalink
logging: update header timestamp on rollover
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jan 9, 2025
1 parent ab87e15 commit a280308
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()

Check warning on line 242 in cylc/flow/loggingutil.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/loggingutil.py#L242

Added line #L242 was not covered by tests
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

Check warning on line 256 in cylc/flow/loggingutil.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/loggingutil.py#L256

Added line #L256 was not covered by tests

logging.FileHandler.emit(self, header_record)

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

0 comments on commit a280308

Please sign in to comment.