jason810496 commented on code in PR #45129:
URL: https://github.com/apache/airflow/pull/45129#discussion_r1959228856
##########
airflow/utils/log/file_task_handler.py:
##########
@@ -107,30 +131,111 @@ def _parse_timestamp(line: str):
return pendulum.parse(timestamp_str.strip("[]"))
-def _parse_timestamps_in_log_file(lines: Iterable[str]):
- timestamp = None
- next_timestamp = None
- for idx, line in enumerate(lines):
- if line:
- with suppress(Exception):
- # next_timestamp unchanged if line can't be parsed
- next_timestamp = _parse_timestamp(line)
- if next_timestamp:
- timestamp = next_timestamp
- yield timestamp, idx, line
+def _get_parsed_log_stream(file_path: Path) -> _ParsedLogStreamType:
+ with open(file_path) as f:
+ line_num = 0 # line number for each log line
+ for file_chunk in iter(partial(f.read, CHUNK_SIZE), b""):
+ if not file_chunk:
+ break
+ # parse log lines
+ lines = file_chunk.splitlines()
+ timestamp = None
+ next_timestamp = None
+ for line in lines:
+ if line:
Review Comment:
After checking, there is not need for `if line:` part.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]