mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-19 04:46:08 +00:00
Improve logging
This commit is contained in:
1 parent
0df17c1bc7
commit
4c95be694f
5 files changed
+23
-12
No files matched your search
@@ -513,10 +513,12 @@ class InboundNearbyConnection: NearbyConnection {
|
|||||||
#endif
|
#endif
|
||||||
filesToBeReceived[id]!.progress = progress
|
filesToBeReceived[id]!.progress = progress
|
||||||
filesToBeReceived[id]!.created = true
|
filesToBeReceived[id]!.created = true
|
||||||
|
|
||||||
log("[InboundNearbyConnection \(self.id)] Accepted file with size \(file.meta.size)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let totalBytes = filesToBeReceived.values.reduce(0) { $0 + $1.meta.size }
|
||||||
|
let gigabytes = Double(totalBytes) / 1_000_000_000
|
||||||
|
log("[InboundNearbyConnection \(self.id)] Accepted \(filesToBeReceived.count) file(s) with size \(totalBytes) bytes (\(gigabytes) GB)")
|
||||||
|
|
||||||
var frame = Sharing_Nearby_Frame()
|
var frame = Sharing_Nearby_Frame()
|
||||||
frame.version = .v1
|
frame.version = .v1
|
||||||
frame.v1.type = .response
|
frame.v1.type = .response
|
||||||
|
|||||||
@@ -207,8 +207,7 @@ class NearbyConnection {
|
|||||||
log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:)")
|
log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:)")
|
||||||
|
|
||||||
if let content = content, !content.isEmpty {
|
if let content = content, !content.isEmpty {
|
||||||
log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), but trying to process the frame anyway. Frame length: \(content.count)")
|
log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), and frame not empty. Frame length: \(content.count)")
|
||||||
self.processReceivedFrame(frameData: content)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), but no content received anymore (\(String(describing: content))).")
|
log("[NearbyConnection \(self.id)] Connection closed by peer during receiveFrameAsync(length:), but no content received anymore (\(String(describing: content))).")
|
||||||
@@ -424,7 +423,10 @@ class NearbyConnection {
|
|||||||
}
|
}
|
||||||
else if offlineFrame.hasV1, offlineFrame.v1.hasType, case .keepAlive = offlineFrame.v1.type {
|
else if offlineFrame.hasV1, offlineFrame.v1.hasType, case .keepAlive = offlineFrame.v1.type {
|
||||||
|
|
||||||
log("[NearbyConnection \(self.id)] Sent keep-alive, \(self.bytesTransferred) bytes sent")
|
let bytesTransferred = self.bytesTransferred
|
||||||
|
let gigabytesTransferred = Double(bytesTransferred) / 1_000_000_000
|
||||||
|
|
||||||
|
log("[NearbyConnection \(self.id)] Sent keep-alive, \(self.bytesTransferred) bytes (\(gigabytesTransferred) GB) sent")
|
||||||
sendKeepAlive(ack: true)
|
sendKeepAlive(ack: true)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
|
|
||||||
let queue2 = DispatchQueue(label: "NetworkConnectionMonitor")
|
let queue2 = DispatchQueue(label: "NetworkConnectionMonitor")
|
||||||
hasConnectionMonitor.start(queue: queue2)
|
hasConnectionMonitor.start(queue: queue2)
|
||||||
|
|
||||||
|
log("Application did finish launching")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -147,10 +149,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
func application(_ application: NSApplication, open urls: [URL]) {
|
func application(_ application: NSApplication, open urls: [URL]) {
|
||||||
for url in urls {
|
for url in urls {
|
||||||
if url.scheme == "quickdrop", url.host == "sendLog" {
|
if url.scheme == "quickdrop", url.host == "sendLog" {
|
||||||
sendLoggingString() // this time it runs in the main app
|
sendLoggingString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if url.scheme == "quickdrop", url.host == "openLog", let url = LogManager.sharedInstance.logFileURL {
|
if url.scheme == "quickdrop", url.host == "openLog", let url = LogManager.sharedInstance.logFileURL {
|
||||||
log("Opening log file: \(url)")
|
log("Opening log file: \(url)")
|
||||||
// open folder containing the log file
|
// open folder containing the log file
|
||||||
|
|||||||
@@ -7157,6 +7157,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Reset UD" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"SaveFilesLocation" : {
|
"SaveFilesLocation" : {
|
||||||
"extractionState" : "manual",
|
"extractionState" : "manual",
|
||||||
|
|||||||
@@ -148,12 +148,15 @@ func sendLoggingString() {
|
|||||||
if let url = LogManager.sharedInstance.logFileURL {
|
if let url = LogManager.sharedInstance.logFileURL {
|
||||||
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
|
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
|
||||||
log("Sending logging string with file URL: \(url)")
|
log("Sending logging string with file URL: \(url)")
|
||||||
|
log("Currently running apps: \(NSWorkspace.shared.runningApplications.map { $0.localizedName ?? "Unknown" })")
|
||||||
|
|
||||||
sendEmailWithAttachment(
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
|
||||||
fileURL: url,
|
sendEmailWithAttachment(
|
||||||
recipients: ["quickdrop@leonboettger.com"],
|
fileURL: url,
|
||||||
subject: "QuickDrop \(appVersion) - \(getDeviceAndSystem())"
|
recipients: ["quickdrop@leonboettger.com"],
|
||||||
)
|
subject: "QuickDrop \(appVersion) - \(getDeviceAndSystem())"
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user