import tkinter as tk from tkinter import filedialog def format_log_for_discord(log_data): discord_message = "```ini\n" # Start with ini block for device info # Iterate over log data lines and filter for device info, warnings, and errors for line in log_data.splitlines(): # Remove lines with , and keep errors, warnings, and device info if "" not in line and any(keyword in line for keyword in ["", "", "", "Device", "SoC", "Memory"]): if "" in line or "" in line: discord_message += f"🛑 [ERROR] {line}\n" elif "" in line: discord_message += f"⚠️ [WARNING] {line}\n" else: discord_message += f"{line}\n" # Keep device info in ini format discord_message += "```\n" # Close ini block return discord_message def open_file_and_format(): # Open file dialog to select the log file filepath = filedialog.askopenfilename(title="Select a log file") if filepath: with open(filepath, 'r') as file: log_data = file.read() formatted_log = format_log_for_discord(log_data) # Show the formatted log in a new window (for copying) output_window = tk.Tk() output_window.title("Discord Formatted Log") text_widget = tk.Text(output_window) text_widget.insert(tk.END, formatted_log) text_widget.pack(expand=True, fill=tk.BOTH) output_window.mainloop() # Set up the main Tkinter window root = tk.Tk() root.withdraw() # Hide the main window, only show file dialog # Trigger file opening and formatting open_file_and_format()