diff --git a/BrewBar/BrewBarApp.swift b/BrewBar/BrewBarApp.swift index be2a4fd..9db5507 100644 --- a/BrewBar/BrewBarApp.swift +++ b/BrewBar/BrewBarApp.swift @@ -344,9 +344,16 @@ class AppDelegate: NSObject, NSApplicationDelegate { // MARK: - Logs + /// oldest content is dropped past this size, or the buffer grows forever + /// and every log() re-renders an ever-larger string into the text view + let maxLogLength = 100_000 + func log(_ text: String) { DispatchQueue.main.async { self.logBuffer += text + if self.logBuffer.count > self.maxLogLength { + self.logBuffer = String(self.logBuffer.suffix(self.maxLogLength)) + } self.logWindow?.update(text: self.logBuffer) } }