From fac4b552424ce0a8ffd61fef95d46e7166cfbecd Mon Sep 17 00:00:00 2001 From: bnux Date: Sat, 11 Apr 2026 17:15:26 -0700 Subject: [PATCH 1/2] Add timestamp to exported application log filename Exported logs were always named "Meshtastic Application Logs.csv", making it difficult to differentiate between multiple exports. The default filename now includes a timestamp in yyyy-MM-dd_HHmmss format. --- Meshtastic/Views/Settings/AppLog.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index 08c09664..b9583b29 100644 --- a/Meshtastic/Views/Settings/AppLog.swift +++ b/Meshtastic/Views/Settings/AppLog.swift @@ -171,7 +171,7 @@ struct AppLog: View { isPresented: $isExporting, document: CsvDocument(emptyCsv: exportString), contentType: .commaSeparatedText, - defaultFilename: String("Meshtastic Application Logs"), + defaultFilename: "Meshtastic Application Logs \({ let f = DateFormatter(); f.dateFormat = "yyyy-MM-dd_HHmmss"; return f.string(from: .now) }())", onCompletion: { result in switch result { case .success: From 52d98cc283317d994f941fa1879dffc2013ba64f Mon Sep 17 00:00:00 2001 From: bnux Date: Thu, 16 Apr 2026 13:40:11 -0700 Subject: [PATCH 2/2] Move DateFormatter to static let and use @State for export filename Addresses review feedback: avoids creating a new DateFormatter on every SwiftUI body recomputation by using a static let, and captures the timestamp once per export via a @State property. --- Meshtastic/Views/Settings/AppLog.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index b9583b29..709d3fa9 100644 --- a/Meshtastic/Views/Settings/AppLog.swift +++ b/Meshtastic/Views/Settings/AppLog.swift @@ -21,9 +21,15 @@ struct AppLog: View { @State private var levels: Set = [] @State var isExporting = false @State var exportString = "" + @State var exportFilename = "Meshtastic Application Logs" @State var isEditingFilters = false private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } + private static let logFileDateFormatter: DateFormatter = { + let f = DateFormatter() + f.dateFormat = "yyyy-MM-dd_HHmmss" + return f + }() private let dateFormatStyle = Date.FormatStyle() .hour(.twoDigits(amPM: .omitted)) .minute() @@ -171,7 +177,7 @@ struct AppLog: View { isPresented: $isExporting, document: CsvDocument(emptyCsv: exportString), contentType: .commaSeparatedText, - defaultFilename: "Meshtastic Application Logs \({ let f = DateFormatter(); f.dateFormat = "yyyy-MM-dd_HHmmss"; return f.string(from: .now) }())", + defaultFilename: exportFilename, onCompletion: { result in switch result { case .success: @@ -200,6 +206,7 @@ struct AppLog: View { ToolbarItem(placement: .navigationBarTrailing) { Button(action: { exportString = logToCsvFile(log: logs) + exportFilename = "Meshtastic Application Logs \(Self.logFileDateFormatter.string(from: .now))" isExporting = true }) { Image(systemName: "square.and.arrow.down")