|
11 | 11 | import os
|
12 | 12 | import signal
|
13 | 13 | import sys
|
| 14 | +import time |
14 | 15 | from codecs import StreamWriter, getwriter # pylint: disable=unused-import
|
15 | 16 | from typing import (IO, Any, Callable, Dict, Iterable, List, Mapping,
|
16 | 17 | MutableMapping, MutableSequence, Optional, TextIO, Tuple,
|
@@ -551,8 +552,19 @@ def main(argsl=None, # type: List[str]
|
551 | 552 | runtimeContext.research_obj.folder, "log")
|
552 | 553 | prov_log_handler = logging.FileHandler(
|
553 | 554 | str(prov_log_handler_filename))
|
554 |
| - if formatter: |
555 |
| - prov_log_handler.setFormatter(formatter) |
| 555 | + class ProvLogFormatter(logging.Formatter): |
| 556 | + """Enforce ISO8601 with both T and Z.""" |
| 557 | + def __init__(self): # type: () -> None |
| 558 | + super(ProvLogFormatter, self).__init__( |
| 559 | + "[%(asctime)sZ] %(message)s") |
| 560 | + |
| 561 | + def formatTime(self, record, datefmt=None): |
| 562 | + # type: (logging.LogRecord, str) -> str |
| 563 | + record_time = time.gmtime(record.created) |
| 564 | + formatted_time = time.strftime("%Y-%m-%dT%H:%M:%S", record_time) |
| 565 | + with_msecs = "%s,%03d" % (formatted_time, record.msecs) |
| 566 | + return with_msecs |
| 567 | + prov_log_handler.setFormatter(ProvLogFormatter()) |
556 | 568 | _logger.addHandler(prov_log_handler)
|
557 | 569 |
|
558 | 570 | if loadingContext is None:
|
|
0 commit comments