Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions multiparser/parsing/tail.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ def _wrapper(*args, file_content, **kwargs) -> TimeStampedData:
raise RuntimeError("Failed to retrieve argument '__read_bytes'")
if not (_input_file := kwargs.get("__input_file")):
raise RuntimeError("Failed to retrieve argument '__input_file'")
_time_stamp = datetime.datetime.fromtimestamp(
timestamp=os.path.getmtime(_input_file), tz=datetime.timezone.utc
)
_meta_data: dict[str, str] = {
"timestamp": datetime.datetime.fromtimestamp(
os.path.getmtime(_input_file)
).strftime("%Y-%m-%d %H:%M:%S.%f"),
"timestamp": f"{_time_stamp}",
"hostname": platform.node(),
"file_name": _input_file,
"__read_bytes": kwargs["__read_bytes"],
Expand Down Expand Up @@ -607,7 +608,7 @@ def record_log(
__read_bytes=__read_bytes,
tracked_values=tracked_values,
convert=convert,
**parser_kwargs
**parser_kwargs,
)
_data.append(_processed) # type: ignore
_metadata = _metadata or _metadata_line
Expand Down
12 changes: 6 additions & 6 deletions multiparser/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _append_thread(
parser_func: typing.Callable | None = None,
file_type: str | None = None,
glob_expr: str | None = None,
**parser_kwargs
**parser_kwargs,
) -> None:
"""Create a new thread for a monitored file

Expand Down Expand Up @@ -366,11 +366,11 @@ def _read_loop(

_modified_time_stamp = os.path.getmtime(file_name)
_modified_time = datetime.datetime.fromtimestamp(
_modified_time_stamp
).strftime("%Y-%M-%d %H:%M:%S.%f")
timestamp=_modified_time_stamp, tz=datetime.timezone.utc
)

# If the file has not been modified then we do not need to parse it
if (_modified_time, file_name) in records:
if (f"{_modified_time}", file_name) in records:
continue
_cached_metadata = _reparse_action(
file_type=file_type,
Expand All @@ -382,11 +382,11 @@ def _read_loop(
lock=self._lock,
flatten_data=flatten_data,
cached_metadata=_cached_metadata,
modified_time=_modified_time,
modified_time=f"{_modified_time}",
**kwargs,
)

records.append((_modified_time, file_name))
records.append((f"{_modified_time}", file_name))

# If only a single read is required terminate loop
if static_read:
Expand Down