From 1539e1331e5ff883cc9a083c8108c6fa57400d2d Mon Sep 17 00:00:00 2001 From: neoarz Date: Sat, 29 Mar 2025 05:03:55 -0400 Subject: [PATCH] log manager --- StikJIT/Utilities/LogManager.swift | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/StikJIT/Utilities/LogManager.swift b/StikJIT/Utilities/LogManager.swift index eacd36f..160abca 100644 --- a/StikJIT/Utilities/LogManager.swift +++ b/StikJIT/Utilities/LogManager.swift @@ -34,8 +34,26 @@ class LogManager: ObservableObject { } func addLog(message: String, type: LogEntry.LogType) { + // Remove redundant prefixes from the message + var cleanMessage = message + + // Clean up common prefixes that match the log type + let prefixesToRemove = [ + "Info: ", "INFO: ", "Information: ", + "Error: ", "ERROR: ", "ERR: ", + "Debug: ", "DEBUG: ", "DBG: ", + "Warning: ", "WARN: ", "WARNING: " + ] + + for prefix in prefixesToRemove { + if cleanMessage.hasPrefix(prefix) { + cleanMessage = String(cleanMessage.dropFirst(prefix.count)) + break + } + } + DispatchQueue.main.async { - self.logs.append(LogEntry(timestamp: Date(), type: type, message: message)) + self.logs.append(LogEntry(timestamp: Date(), type: type, message: cleanMessage)) if type == .error { self.errorCount += 1