Open log file with UTF-8 encoding

Specify encoding='utf-8' when opening the log file in append mode to ensure non-ASCII characters are written correctly and to avoid Unicode-related errors when writing log entries.
This commit is contained in:
Anand G 2026-03-08 19:17:24 +05:30
parent f047f26df0
commit 7988285330
1 changed files with 1 additions and 1 deletions

View File

@ -948,7 +948,7 @@ def run_analysis():
func(*args, **kwargs)
timestamp, message_type, content = obj.messages[-1]
content = content.replace("\n", " ") # Replace newlines with spaces
with open(log_file, "a") as f:
with open(log_file, "a", encoding="utf-8") as f:
f.write(f"{timestamp} [{message_type}] {content}\n")
return wrapper