Minor logging tweaks

pull/1018/head
Morgan Pretty 7 months ago
parent d8294aac0d
commit a7e73080fa

@ -1 +1 @@
Subproject commit 6a1ab5168ff2cd2f967d804ea6e1130a939f2189
Subproject commit 12ed513d4fed91ba2ff1fda07b3ae62101d4baa5

@ -7706,7 +7706,7 @@
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 485;
CURRENT_PROJECT_VERSION = 486;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -7784,7 +7784,7 @@
CLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 485;
CURRENT_PROJECT_VERSION = 486;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;

@ -192,7 +192,7 @@ extension ConversationVC:
threadVariant: SessionThread.Variant,
messageText: String?
) {
sendMessage(text: (messageText ?? ""), attachments: attachments, using: viewModel.dependencies)
sendMessage(text: (messageText ?? ""), attachments: attachments)
resetMentions()
dismiss(animated: true) { [weak self] in
@ -222,7 +222,7 @@ extension ConversationVC:
threadVariant: SessionThread.Variant,
messageText: String?
) {
sendMessage(text: (messageText ?? ""), attachments: attachments, using: viewModel.dependencies)
sendMessage(text: (messageText ?? ""), attachments: attachments)
resetMentions()
dismiss(animated: true) { [weak self] in
@ -467,8 +467,7 @@ extension ConversationVC:
attachments: [SignalAttachment] = [],
linkPreviewDraft: LinkPreviewDraft? = nil,
quoteModel: QuotedReplyModel? = nil,
hasPermissionToSendSeed: Bool = false,
using dependencies: Dependencies = Dependencies()
hasPermissionToSendSeed: Bool = false
) {
guard !showBlockedModalIfNeeded() else { return }
@ -539,17 +538,14 @@ extension ConversationVC:
quoteModel: quoteModel
)
sendMessage(optimisticData: optimisticData, using: dependencies)
sendMessage(optimisticData: optimisticData)
}
private func sendMessage(
optimisticData: ConversationViewModel.OptimisticMessageData,
using dependencies: Dependencies
) {
private func sendMessage(optimisticData: ConversationViewModel.OptimisticMessageData) {
let threadId: String = self.viewModel.threadData.threadId
let threadVariant: SessionThread.Variant = self.viewModel.threadData.threadVariant
DispatchQueue.global(qos:.userInitiated).async(using: dependencies) {
DispatchQueue.global(qos:.userInitiated).async(using: viewModel.dependencies) { [dependencies = viewModel.dependencies] in
// Generate the quote thumbnail if needed (want this to happen outside of the DBWrite thread as
// this can take up to 0.5s
let quoteThumbnailAttachment: Attachment? = optimisticData.quoteModel?.attachment?.cloneAsQuoteThumbnail()
@ -1905,7 +1901,7 @@ extension ConversationVC:
}
// Try to send the optimistic message again
sendMessage(optimisticData: optimisticMessageData, using: dependencies)
sendMessage(optimisticData: optimisticMessageData)
return
}
@ -2617,7 +2613,7 @@ extension ConversationVC:
}
// Send attachment
sendMessage(text: "", attachments: [attachment], using: dependencies)
sendMessage(text: "", attachments: [attachment])
}
func cancelVoiceMessageRecording() {

@ -23,7 +23,7 @@ public enum MessageSendJob: JobExecutor {
let detailsData: Data = job.details,
let details: Details = try? JSONDecoder().decode(Details.self, from: detailsData)
else {
Log.error("[MessageSendJob] Failing due to missing details")
Log.error("[MessageSendJob] Failing (\(job.id ?? -1)) due to missing details")
return failure(job, JobRunnerError.missingRequiredDetails, true, dependencies)
}
@ -50,7 +50,7 @@ public enum MessageSendJob: JobExecutor {
let jobId: Int64 = job.id,
let interactionId: Int64 = job.interactionId
else {
Log.error("[MessageSendJob] Failing due to missing details")
Log.error("[MessageSendJob] Failing (\(job.id ?? -1)) due to missing details")
return failure(job, JobRunnerError.missingRequiredDetails, true, dependencies)
}
@ -62,7 +62,7 @@ public enum MessageSendJob: JobExecutor {
// If the original interaction no longer exists then don't bother sending the message (ie. the
// message was deleted before it even got sent)
guard try Interaction.exists(db, id: interactionId) else {
Log.warn("[MessageSendJob] Failing due to missing interaction")
Log.warn("[MessageSendJob] Failing (\(job.id ?? -1)) due to missing interaction")
return (StorageError.objectNotFound, [], [])
}
@ -78,7 +78,7 @@ public enum MessageSendJob: JobExecutor {
// If there were failed attachments then this job should fail (can't send a
// message which has associated attachments if the attachments fail to upload)
guard !allAttachmentStateInfo.contains(where: { $0.state == .failedDownload }) else {
Log.info("[MessageSendJob] Failing due to failed attachment upload")
Log.info("[MessageSendJob] Failing (\(job.id ?? -1)) due to failed attachment upload")
return (AttachmentError.notUploaded, [], fileIds)
}
@ -157,7 +157,7 @@ public enum MessageSendJob: JobExecutor {
}
}
Log.info("[MessageSendJob] Deferring due to pending attachment uploads")
Log.info("[MessageSendJob] Deferring (\(job.id ?? -1)) due to pending attachment uploads")
return deferred(job, dependencies)
}
@ -193,11 +193,11 @@ public enum MessageSendJob: JobExecutor {
receiveCompletion: { result in
switch result {
case .finished:
Log.info("[MessageSendJob] Completed sending \(messageType) after \(.seconds(dependencies.dateNow.timeIntervalSince1970 - startTime), unit: .s).")
Log.info("[MessageSendJob] Completed sending \(messageType) (\(job.id ?? -1)) after \(.seconds(dependencies.dateNow.timeIntervalSince1970 - startTime), unit: .s).")
success(job, false, dependencies)
case .failure(let error):
Log.info("[MessageSendJob] Failed to send \(messageType) after \(.seconds(dependencies.dateNow.timeIntervalSince1970 - startTime), unit: .s) due to error: \(error).")
Log.info("[MessageSendJob] Failed to send \(messageType) (\(job.id ?? -1)) after \(.seconds(dependencies.dateNow.timeIntervalSince1970 - startTime), unit: .s) due to error: \(error).")
// Actual error handling
switch (error, details.message) {
@ -208,7 +208,7 @@ public enum MessageSendJob: JobExecutor {
failure(job, error, true, dependencies)
case (SnodeAPIError.clockOutOfSync, _):
Log.error("[MessageSendJob] \(originalSentTimestamp != nil ? "Permanently Failing" : "Failing") to send \(type(of: details.message)) due to clock out of sync issue.")
Log.error("[MessageSendJob] \(originalSentTimestamp != nil ? "Permanently Failing" : "Failing") to send \(type(of: details.message)) (\(job.id ?? -1)) due to clock out of sync issue.")
failure(job, error, (originalSentTimestamp != nil), dependencies)
// Don't bother retrying (it can just send a new one later but allowing retries

@ -573,7 +573,8 @@ public extension LibSession {
case (401, _):
Log.warn("Unauthorised (Failed to verify the signature).")
throw NetworkError.unauthorised
case (403, _): throw NetworkError.forbidden
case (404, _): throw NetworkError.notFound
/// A snode will return a `406` but onion requests v4 seems to return `425` so handle both

@ -7,6 +7,7 @@ import Foundation
public enum NetworkError: Error, Equatable, CustomStringConvertible {
case invalidURL
case invalidPreparedRequest
case forbidden
case notFound
case parsingFailed
case invalidResponse
@ -26,6 +27,7 @@ public enum NetworkError: Error, Equatable, CustomStringConvertible {
switch self {
case .invalidURL: return "Invalid URL (NetworkError.invalidURL)."
case .invalidPreparedRequest: return "Invalid PreparedRequest provided (NetworkError.invalidPreparedRequest)."
case .forbidden: return "Forbidden (NetworkError.forbidden)."
case .notFound: return "Not Found (NetworkError.notFound)."
case .parsingFailed: return "Invalid response (NetworkError.parsingFailed)."
case .invalidResponse: return "Invalid response (NetworkError.invalidResponse)."

Loading…
Cancel
Save