Fix frigate log deduplication (#16759)

This commit is contained in:
Josh Hawkins 2025-02-23 07:25:50 -06:00 committed by GitHub
parent 71f1ea86d2
commit 22cbf74dc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -659,10 +659,22 @@ def process_logs(
if " " not in clean_line: if " " not in clean_line:
clean_line = f"{datetime.now()} {clean_line}" clean_line = f"{datetime.now()} {clean_line}"
try:
# Find the position of the first double space to extract timestamp and message # Find the position of the first double space to extract timestamp and message
date_end = clean_line.index(" ") date_end = clean_line.index(" ")
timestamp = clean_line[:date_end] timestamp = clean_line[:date_end]
message_part = clean_line[date_end:].strip() full_message = clean_line[date_end:].strip()
# For frigate, remove the date part from message comparison
if service == "frigate":
# Skip the date at the start of the message if it exists
date_parts = full_message.split("]", 1)
if len(date_parts) > 1:
message_part = date_parts[1].strip()
else:
message_part = full_message
else:
message_part = full_message
if message_part == last_message: if message_part == last_message:
repeat_count += 1 repeat_count += 1
@ -679,6 +691,11 @@ def process_logs(
last_message = message_part last_message = message_part
except ValueError:
# If we can't parse the line properly, just add it as is
log_lines.append(clean_line)
continue
# If there were repeated messages at the end, log the count # If there were repeated messages at the end, log the count
if repeat_count > 0: if repeat_count > 0:
dedup_message = ( dedup_message = (