diff --git a/MatrixSDK.xcodeproj/project.pbxproj b/MatrixSDK.xcodeproj/project.pbxproj index 1f4342640f..40cdc589fa 100644 --- a/MatrixSDK.xcodeproj/project.pbxproj +++ b/MatrixSDK.xcodeproj/project.pbxproj @@ -29,10 +29,6 @@ 18121F7E273E837300B68ADF /* PollModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18121F7C273E835D00B68ADF /* PollModels.swift */; }; 18121F7F273E837300B68ADF /* PollModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18121F7C273E835D00B68ADF /* PollModels.swift */; }; 18121F80273E837400B68ADF /* PollModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18121F7C273E835D00B68ADF /* PollModels.swift */; }; - 181FD5D42660C791008EC084 /* MXLogObjcWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 181FD5D22660C791008EC084 /* MXLogObjcWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 181FD5D52660C791008EC084 /* MXLogObjcWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 181FD5D22660C791008EC084 /* MXLogObjcWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 181FD5D62660C791008EC084 /* MXLogObjcWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 181FD5D32660C791008EC084 /* MXLogObjcWrapper.m */; }; - 181FD5D72660C791008EC084 /* MXLogObjcWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 181FD5D32660C791008EC084 /* MXLogObjcWrapper.m */; }; 183892762702F553003F0C4F /* MXRoomNameDefaultStringLocalizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1838926F2702F552003F0C4F /* MXRoomNameDefaultStringLocalizer.h */; }; 183892772702F553003F0C4F /* MXRoomNameDefaultStringLocalizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1838926F2702F552003F0C4F /* MXRoomNameDefaultStringLocalizer.h */; }; 1838927A2702F553003F0C4F /* MXSendReplyEventDefaultStringLocalizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 183892712702F553003F0C4F /* MXSendReplyEventDefaultStringLocalizer.m */; }; @@ -47,10 +43,6 @@ 1838928927031D1D003F0C4F /* MXSendReplyEventStringLocalizerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 1838928527031D1D003F0C4F /* MXSendReplyEventStringLocalizerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18937E7C273A5AE500902626 /* MXPollRelationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18937E79273A5AB000902626 /* MXPollRelationTests.m */; }; 18937E7D273A5AE500902626 /* MXPollRelationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18937E79273A5AB000902626 /* MXPollRelationTests.m */; }; - 189CC081265E361C00BE1FD8 /* MXLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 189CC07F265E361500BE1FD8 /* MXLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 189CC082265E361D00BE1FD8 /* MXLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 189CC07F265E361500BE1FD8 /* MXLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 189CC083265E362600BE1FD8 /* MXLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 189CC080265E361500BE1FD8 /* MXLog.swift */; }; - 189CC084265E362700BE1FD8 /* MXLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 189CC080265E361500BE1FD8 /* MXLog.swift */; }; 18B22A7027707CDD00482170 /* MXEventContentLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 18B22A6E27707CDD00482170 /* MXEventContentLocation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18B22A7127707CDD00482170 /* MXEventContentLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 18B22A6E27707CDD00482170 /* MXEventContentLocation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18B22A7227707CDD00482170 /* MXEventContentLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B22A6F27707CDD00482170 /* MXEventContentLocation.m */; }; @@ -374,8 +366,6 @@ 327C3E4C23A39D91006183D1 /* MXAggregatedReferencesUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 327C3E4923A39D91006183D1 /* MXAggregatedReferencesUpdater.h */; }; 327C3E4D23A39D91006183D1 /* MXAggregatedReferencesUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 327C3E4A23A39D91006183D1 /* MXAggregatedReferencesUpdater.m */; }; 327C3E4E23A39D91006183D1 /* MXAggregatedReferencesUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 327C3E4A23A39D91006183D1 /* MXAggregatedReferencesUpdater.m */; }; - 327E37B61A974F75007F026F /* MXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E37B41A974F75007F026F /* MXLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 327E37B71A974F75007F026F /* MXLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B51A974F75007F026F /* MXLogger.m */; }; 327E37B91A977810007F026F /* MXLoggerUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B81A977810007F026F /* MXLoggerUnitTests.m */; }; 327E9ABC2284521C00A98BC1 /* MXEventUnsignedData.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E9ABA2284521C00A98BC1 /* MXEventUnsignedData.h */; settings = {ATTRIBUTES = (Public, ); }; }; 327E9ABD2284521C00A98BC1 /* MXEventUnsignedData.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E9ABB2284521C00A98BC1 /* MXEventUnsignedData.m */; }; @@ -983,7 +973,6 @@ B14EF2532397E90400758AF0 /* MXPushRuleSenderNotificationPermissionConditionChecker.m in Sources */ = {isa = PBXBuildFile; fileRef = 3240969C1F9F751600DBA607 /* MXPushRuleSenderNotificationPermissionConditionChecker.m */; }; B14EF2542397E90400758AF0 /* MXReceiptData.m in Sources */ = {isa = PBXBuildFile; fileRef = 71DE22DC1BC7C51200284153 /* MXReceiptData.m */; }; B14EF2552397E90400758AF0 /* MXWellKnownBaseConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 323547D72226D5D600F15F94 /* MXWellKnownBaseConfig.m */; }; - B14EF2562397E90400758AF0 /* MXLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 327E37B51A974F75007F026F /* MXLogger.m */; }; B14EF2572397E90400758AF0 /* MXMegolmExportEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = 324BE4671E3FADB1008D99D4 /* MXMegolmExportEncryption.m */; }; B14EF2582397E90400758AF0 /* MXFilterObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 32A31BBD20D3F2EC005916C7 /* MXFilterObject.m */; }; B14EF2592397E90400758AF0 /* MXHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 320DFDD819DD99B60068622A /* MXHTTPClient.m */; }; @@ -1230,7 +1219,6 @@ B14EF35A2397E90400758AF0 /* MXReplyEventFormattedBodyParts.h in Headers */ = {isa = PBXBuildFile; fileRef = B11BD45722CB58850064D8B0 /* MXReplyEventFormattedBodyParts.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF35B2397E90400758AF0 /* MXKeyBackupData.h in Headers */ = {isa = PBXBuildFile; fileRef = 32BBAE6A2178E99100D85F46 /* MXKeyBackupData.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF35C2397E90400758AF0 /* MXPusher.h in Headers */ = {isa = PBXBuildFile; fileRef = 32999DDD22DCD183004FF987 /* MXPusher.h */; settings = {ATTRIBUTES = (Public, ); }; }; - B14EF35D2397E90400758AF0 /* MXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 327E37B41A974F75007F026F /* MXLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF35E2397E90400758AF0 /* MXMegolmBackupCreationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 320A883A217F4E35002EA952 /* MXMegolmBackupCreationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF35F2397E90400758AF0 /* MXCryptoConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 3256E37F1DCB91EB003C9718 /* MXCryptoConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF3602397E90400758AF0 /* MXHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 320DFDD719DD99B60068622A /* MXHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1842,6 +1830,20 @@ ED51943D284630090006EEC6 /* MXRestClientStub.m in Sources */ = {isa = PBXBuildFile; fileRef = ED51943B284630090006EEC6 /* MXRestClientStub.m */; }; ED5AE8C52816C8CF00105072 /* MXCoreDataRoomSummaryStore.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = ED5AE8C22816C8CF00105072 /* MXCoreDataRoomSummaryStore.xcdatamodeld */; }; ED5AE8C62816C8CF00105072 /* MXCoreDataRoomSummaryStore.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = ED5AE8C22816C8CF00105072 /* MXCoreDataRoomSummaryStore.xcdatamodeld */; }; + ED5C753C28B3E80300D24E85 /* MXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5C753528B3E80300D24E85 /* MXLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED5C753D28B3E80300D24E85 /* MXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5C753528B3E80300D24E85 /* MXLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED5C753E28B3E80300D24E85 /* MXLog.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5C753628B3E80300D24E85 /* MXLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED5C753F28B3E80300D24E85 /* MXLog.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5C753628B3E80300D24E85 /* MXLog.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED5C754028B3E80300D24E85 /* MXLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753728B3E80300D24E85 /* MXLog.swift */; }; + ED5C754128B3E80300D24E85 /* MXLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753728B3E80300D24E85 /* MXLog.swift */; }; + ED5C754228B3E80300D24E85 /* MXAnalyticsDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753828B3E80300D24E85 /* MXAnalyticsDestination.swift */; }; + ED5C754328B3E80300D24E85 /* MXAnalyticsDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753828B3E80300D24E85 /* MXAnalyticsDestination.swift */; }; + ED5C754428B3E80300D24E85 /* MXLogObjcWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753928B3E80300D24E85 /* MXLogObjcWrapper.m */; }; + ED5C754528B3E80300D24E85 /* MXLogObjcWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753928B3E80300D24E85 /* MXLogObjcWrapper.m */; }; + ED5C754628B3E80300D24E85 /* MXLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753A28B3E80300D24E85 /* MXLogger.m */; }; + ED5C754728B3E80300D24E85 /* MXLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = ED5C753A28B3E80300D24E85 /* MXLogger.m */; }; + ED5C754828B3E80300D24E85 /* MXLogObjcWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5C753B28B3E80300D24E85 /* MXLogObjcWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED5C754928B3E80300D24E85 /* MXLogObjcWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5C753B28B3E80300D24E85 /* MXLogObjcWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; ED5C95CE2833E85600843D82 /* MXOlmDeviceUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5C95CD2833E85600843D82 /* MXOlmDeviceUnitTests.swift */; }; ED5C95CF2833E85600843D82 /* MXOlmDeviceUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED5C95CD2833E85600843D82 /* MXOlmDeviceUnitTests.swift */; }; ED7019DD2886C24100FC31B9 /* MXCrossSigningInfoSourceUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED8F1D242885A39800F897E7 /* MXCrossSigningInfoSourceUnitTests.swift */; }; @@ -1982,8 +1984,6 @@ 18121F73273E6CED00B68ADF /* MXPollBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXPollBuilderTests.swift; sourceTree = ""; }; 18121F77273E6E1E00B68ADF /* PollBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollBuilder.swift; sourceTree = ""; }; 18121F7C273E835D00B68ADF /* PollModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollModels.swift; sourceTree = ""; }; - 181FD5D22660C791008EC084 /* MXLogObjcWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXLogObjcWrapper.h; sourceTree = ""; }; - 181FD5D32660C791008EC084 /* MXLogObjcWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXLogObjcWrapper.m; sourceTree = ""; }; 1838926F2702F552003F0C4F /* MXRoomNameDefaultStringLocalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXRoomNameDefaultStringLocalizer.h; sourceTree = ""; }; 183892712702F553003F0C4F /* MXSendReplyEventDefaultStringLocalizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXSendReplyEventDefaultStringLocalizer.m; sourceTree = ""; }; 183892732702F553003F0C4F /* MXSendReplyEventDefaultStringLocalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXSendReplyEventDefaultStringLocalizer.h; sourceTree = ""; }; @@ -1991,8 +1991,6 @@ 1838928427031D1D003F0C4F /* MXRoomNameStringLocalizerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXRoomNameStringLocalizerProtocol.h; sourceTree = ""; }; 1838928527031D1D003F0C4F /* MXSendReplyEventStringLocalizerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXSendReplyEventStringLocalizerProtocol.h; sourceTree = ""; }; 18937E79273A5AB000902626 /* MXPollRelationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXPollRelationTests.m; sourceTree = ""; }; - 189CC07F265E361500BE1FD8 /* MXLog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXLog.h; sourceTree = ""; }; - 189CC080265E361500BE1FD8 /* MXLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXLog.swift; sourceTree = ""; }; 18B22A6E27707CDD00482170 /* MXEventContentLocation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXEventContentLocation.h; sourceTree = ""; }; 18B22A6F27707CDD00482170 /* MXEventContentLocation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXEventContentLocation.m; sourceTree = ""; }; 18C26C3C273C031900805154 /* PollAggregator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollAggregator.swift; sourceTree = ""; }; @@ -2242,8 +2240,6 @@ 327A5F46239805F600ED6329 /* MXKeyVerificationCancel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXKeyVerificationCancel.m; sourceTree = ""; }; 327C3E4923A39D91006183D1 /* MXAggregatedReferencesUpdater.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXAggregatedReferencesUpdater.h; sourceTree = ""; }; 327C3E4A23A39D91006183D1 /* MXAggregatedReferencesUpdater.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXAggregatedReferencesUpdater.m; sourceTree = ""; }; - 327E37B41A974F75007F026F /* MXLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXLogger.h; sourceTree = ""; }; - 327E37B51A974F75007F026F /* MXLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLogger.m; sourceTree = ""; }; 327E37B81A977810007F026F /* MXLoggerUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLoggerUnitTests.m; sourceTree = ""; }; 327E9ABA2284521C00A98BC1 /* MXEventUnsignedData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXEventUnsignedData.h; sourceTree = ""; }; 327E9ABB2284521C00A98BC1 /* MXEventUnsignedData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXEventUnsignedData.m; sourceTree = ""; }; @@ -2929,6 +2925,13 @@ ED51943E284630100006EEC6 /* MXRestClientStub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXRestClientStub.h; sourceTree = ""; }; ED5AE8C32816C8CF00105072 /* MXRoomSummaryCoreDataStore2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MXRoomSummaryCoreDataStore2.xcdatamodel; sourceTree = ""; }; ED5AE8C42816C8CF00105072 /* MXRoomSummaryCoreDataStore.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MXRoomSummaryCoreDataStore.xcdatamodel; sourceTree = ""; }; + ED5C753528B3E80300D24E85 /* MXLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXLogger.h; sourceTree = ""; }; + ED5C753628B3E80300D24E85 /* MXLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXLog.h; sourceTree = ""; }; + ED5C753728B3E80300D24E85 /* MXLog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXLog.swift; sourceTree = ""; }; + ED5C753828B3E80300D24E85 /* MXAnalyticsDestination.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXAnalyticsDestination.swift; sourceTree = ""; }; + ED5C753928B3E80300D24E85 /* MXLogObjcWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLogObjcWrapper.m; sourceTree = ""; }; + ED5C753A28B3E80300D24E85 /* MXLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXLogger.m; sourceTree = ""; }; + ED5C753B28B3E80300D24E85 /* MXLogObjcWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXLogObjcWrapper.h; sourceTree = ""; }; ED5C95CD2833E85600843D82 /* MXOlmDeviceUnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXOlmDeviceUnitTests.swift; sourceTree = ""; }; ED7019E42886C32900FC31B9 /* MXSASTransactionV2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXSASTransactionV2.swift; sourceTree = ""; }; ED7019E72886C33100FC31B9 /* MXKeyVerificationRequestV2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXKeyVerificationRequestV2.swift; sourceTree = ""; }; @@ -3187,6 +3190,7 @@ 323F87712554607A009E9E67 /* Profiling */, 3259D00E2603722A00C365DB /* Protocols */, B146D46E21A5939000D8C2C6 /* Realm */, + ED5C753428B3E80300D24E85 /* Logs */, 32322A491E575F65005DD155 /* MXAllowedCertificates.h */, 32322A4A1E575F65005DD155 /* MXAllowedCertificates.m */, C6FE1EEF1E65C4F7008587E4 /* MXAnalyticsDelegate.h */, @@ -3204,12 +3208,6 @@ 320DFDD819DD99B60068622A /* MXHTTPClient.m */, 32CAB1091A925B41008C5BB9 /* MXHTTPOperation.h */, 32CAB10A1A925B41008C5BB9 /* MXHTTPOperation.m */, - 327E37B41A974F75007F026F /* MXLogger.h */, - 327E37B51A974F75007F026F /* MXLogger.m */, - 189CC07F265E361500BE1FD8 /* MXLog.h */, - 189CC080265E361500BE1FD8 /* MXLog.swift */, - 181FD5D22660C791008EC084 /* MXLogObjcWrapper.h */, - 181FD5D32660C791008EC084 /* MXLogObjcWrapper.m */, F03EF5021DF01596009DF592 /* MXLRUCache.h */, F03EF5031DF01596009DF592 /* MXLRUCache.m */, 324676EB25C15F4600EA855B /* MXMemory.swift */, @@ -5191,6 +5189,20 @@ path = KeySharing; sourceTree = ""; }; + ED5C753428B3E80300D24E85 /* Logs */ = { + isa = PBXGroup; + children = ( + ED5C753528B3E80300D24E85 /* MXLogger.h */, + ED5C753A28B3E80300D24E85 /* MXLogger.m */, + ED5C753628B3E80300D24E85 /* MXLog.h */, + ED5C753728B3E80300D24E85 /* MXLog.swift */, + ED5C753828B3E80300D24E85 /* MXAnalyticsDestination.swift */, + ED5C753B28B3E80300D24E85 /* MXLogObjcWrapper.h */, + ED5C753928B3E80300D24E85 /* MXLogObjcWrapper.m */, + ); + path = Logs; + sourceTree = ""; + }; ED7019ED2886CA6C00FC31B9 /* Verification */ = { isa = PBXGroup; children = ( @@ -5387,7 +5399,6 @@ B146D4E621A5AEF200D8C2C6 /* MXRealmMediaScan.h in Headers */, 32581DE823C8C0C900832EAA /* MXUserTrustLevel.h in Headers */, B146D4EF21A5AF7F00D8C2C6 /* MXRealmEventScan.h in Headers */, - 189CC081265E361C00BE1FD8 /* MXLog.h in Headers */, B146D49C21A5A04300D8C2C6 /* MXMediaScanStoreDelegate.h in Headers */, 32322A4B1E575F65005DD155 /* MXAllowedCertificates.h in Headers */, B14EECD72577DE7A00448735 /* MXLoginSSOIdentityProvider.h in Headers */, @@ -5414,6 +5425,7 @@ 323547D52226D3F500F15F94 /* MXWellKnown.h in Headers */, 32FFB4F0217E146A00C96002 /* MXRecoveryKey.h in Headers */, 32AF928A240EA3880008A0FD /* MXSecretShareSend.h in Headers */, + ED5C754828B3E80300D24E85 /* MXLogObjcWrapper.h in Headers */, B14EECE52577F76100448735 /* MXLoginSSOFlow.h in Headers */, EC8A53E025B1BCC6004E0802 /* MXThirdPartyProtocolInstance.h in Headers */, 91F0685D2767CA420079F8FA /* MXTaskProfileName.h in Headers */, @@ -5449,7 +5461,6 @@ B19A309E240424BD00FB6F35 /* MXQRCodeTransaction_Private.h in Headers */, EC40384A289A7F260067D5B8 /* MXAes256KeyBackupAlgorithm.h in Headers */, 32BBAE742179CF4000D85F46 /* MXKeyBackup.h in Headers */, - 181FD5D42660C791008EC084 /* MXLogObjcWrapper.h in Headers */, 92634B821EF2E3C400DB9F60 /* MXCallKitConfiguration.h in Headers */, 32618E7120ED2DF500E1D2EA /* MXFilterJSONModel.h in Headers */, B146D47221A5939100D8C2C6 /* MXRealmHelper.h in Headers */, @@ -5487,6 +5498,7 @@ 325AD43F23BE3E7500FF5277 /* MXCrossSigningInfo.h in Headers */, 32AF928F24110ADD0008A0FD /* MXSecretShareManager_Private.h in Headers */, B176B25123EB03E4001879C6 /* MXAggregationPaginatedResponse_Private.h in Headers */, + ED5C753E28B3E80300D24E85 /* MXLog.h in Headers */, ECD289B426F9F00E00F268CF /* MXRoomSummarySentStatus.h in Headers */, 021AFBA62179E91900742B2C /* MXEncryptedContentKey.h in Headers */, 327187891DA7DCE50071C818 /* MXOlmEncryption.h in Headers */, @@ -5695,6 +5707,7 @@ 32F945F61FAB83D900622468 /* MXIncomingRoomKeyRequest.h in Headers */, 327137271A24D50A00DB6757 /* MXMyUser.h in Headers */, B146D47C21A5958400D8C2C6 /* MXAntivirusScanStatusFormatter.h in Headers */, + ED5C753C28B3E80300D24E85 /* MXLogger.h in Headers */, 3220093819EFA4C9008DE41D /* MXEventListener.h in Headers */, 327C3E4B23A39D91006183D1 /* MXAggregatedReferencesUpdater.h in Headers */, 324DD2B6246C21C700377005 /* MXSecretStorageKeyCreationInfo.h in Headers */, @@ -5721,7 +5734,6 @@ B11BD45922CB58850064D8B0 /* MXReplyEventFormattedBodyParts.h in Headers */, 32BBAE702178E99100D85F46 /* MXKeyBackupData.h in Headers */, 32999DDF22DCD183004FF987 /* MXPusher.h in Headers */, - 327E37B61A974F75007F026F /* MXLogger.h in Headers */, 320A883C217F4E35002EA952 /* MXMegolmBackupCreationInfo.h in Headers */, B19A30AA2404257700FB6F35 /* MXQRCodeKeyVerificationStart.h in Headers */, B105CDD6261F54C8006EB204 /* MXSpaceChildContent.h in Headers */, @@ -5856,7 +5868,6 @@ B14EF2CB2397E90400758AF0 /* MXCallAudioSessionConfigurator.h in Headers */, B14EF2CC2397E90400758AF0 /* MXMatrixVersions.h in Headers */, 324DD2A1246AE1EF00377005 /* MXEncryptedSecretContent.h in Headers */, - 181FD5D52660C791008EC084 /* MXLogObjcWrapper.h in Headers */, B14EF2CD2397E90400758AF0 /* MXRealmEventScanStore.h in Headers */, B14EF2CE2397E90400758AF0 /* MXFileRoomStore.h in Headers */, B14EF2D02397E90400758AF0 /* MXWellknownIntegrations.h in Headers */, @@ -5890,11 +5901,13 @@ B14EF2E12397E90400758AF0 /* MXContentScanEncryptedBody.h in Headers */, B14EF2E22397E90400758AF0 /* MX3PidAddManager.h in Headers */, B19A309D240424BD00FB6F35 /* MXQRCodeTransaction.h in Headers */, + ED5C753D28B3E80300D24E85 /* MXLogger.h in Headers */, ECD2899F26EB570C00F268CF /* MXRoomSummaryStore.h in Headers */, B14EF2E42397E90400758AF0 /* MXStore.h in Headers */, 32AF928B240EA3880008A0FD /* MXSecretShareSend.h in Headers */, B14EF2E62397E90400758AF0 /* MXMegolmEncryption.h in Headers */, EC8A53E125B1BCC6004E0802 /* MXThirdPartyProtocolInstance.h in Headers */, + ED5C753F28B3E80300D24E85 /* MXLog.h in Headers */, B14EF2E72397E90400758AF0 /* MXLRUCache.h in Headers */, B105CDD7261F54C8006EB204 /* MXSpaceChildContent.h in Headers */, 32AF929824115D8B0008A0FD /* MXPendingSecretShareRequest.h in Headers */, @@ -5960,6 +5973,7 @@ 32261B8B23C74A230018F1E2 /* MXDeviceTrustLevel.h in Headers */, 324DD2B7246C21C700377005 /* MXSecretStorageKeyCreationInfo.h in Headers */, B14EF3102397E90400758AF0 /* MXEmojiRepresentation.h in Headers */, + ED5C754928B3E80300D24E85 /* MXLogObjcWrapper.h in Headers */, EC403857289B26400067D5B8 /* MXBaseKeyBackupAuthData.h in Headers */, EC116596270FBF090089FA56 /* MXApplicationProtocol.h in Headers */, ECF29BCD264194AE0053E6D6 /* MXCallAssertedIdentityEventContent.h in Headers */, @@ -6043,7 +6057,6 @@ B14EF33B2397E90400758AF0 /* MXInvite3PID.h in Headers */, ECD2899926EB3DCF00F268CF /* MXRoomSummaryProtocol.h in Headers */, B14EF33C2397E90400758AF0 /* MXFileStore.h in Headers */, - 189CC082265E361D00BE1FD8 /* MXLog.h in Headers */, B14EF33D2397E90400758AF0 /* MXRealmMediaScanStore.h in Headers */, B14EF3402397E90400758AF0 /* MXKeyBackupVersionTrust.h in Headers */, EC2EACFE266625170038B61F /* MXRoomLastMessage.h in Headers */, @@ -6090,7 +6103,6 @@ B14EF35A2397E90400758AF0 /* MXReplyEventFormattedBodyParts.h in Headers */, B14EF35B2397E90400758AF0 /* MXKeyBackupData.h in Headers */, B14EF35C2397E90400758AF0 /* MXPusher.h in Headers */, - B14EF35D2397E90400758AF0 /* MXLogger.h in Headers */, EC0B943E271DB68F00B4D440 /* MXVoidRoomSummaryStore.h in Headers */, B14EF35E2397E90400758AF0 /* MXMegolmBackupCreationInfo.h in Headers */, B14EF35F2397E90400758AF0 /* MXCryptoConstants.h in Headers */, @@ -6432,7 +6444,6 @@ 32B94E06228EE90300716A26 /* MXRealmReactionRelation.m in Sources */, 66836AB927CFA17200515780 /* MXLiveEventListener.swift in Sources */, 320BBF411D6C81550079890E /* MXEventsByTypesEnumeratorOnArray.m in Sources */, - 181FD5D62660C791008EC084 /* MXLogObjcWrapper.m in Sources */, EC60ED87265CFD0700B39A4E /* MXRoomsSyncResponse.m in Sources */, 3213301E228B190F0070BA9B /* MXRealmAggregationsMapper.m in Sources */, 8EC511062568216B00EC4E5B /* MXTaggedEventInfo.m in Sources */, @@ -6457,6 +6468,7 @@ B17982FC2119E4A2001FD722 /* MXRoomPowerLevels.m in Sources */, B146D4E421A5AEF200D8C2C6 /* MXRealmMediaScanMapper.m in Sources */, B146D4E321A5AEF200D8C2C6 /* MXRealmMediaScan.m in Sources */, + ED5C754628B3E80300D24E85 /* MXLogger.m in Sources */, 3291DC8523DF52E20009732F /* MXRoomCreationParameters.m in Sources */, 32C235731F827F3800E38FC5 /* MXRoomOperation.m in Sources */, 322A51C41D9AC8FE00C8536D /* MXCryptoAlgorithms.m in Sources */, @@ -6516,6 +6528,7 @@ B105CDD8261F54C8006EB204 /* MXSpaceChildContent.m in Sources */, 327E9ABD2284521C00A98BC1 /* MXEventUnsignedData.m in Sources */, 32AF9286240EA2430008A0FD /* MXSecretShareRequest.m in Sources */, + ED5C754428B3E80300D24E85 /* MXLogObjcWrapper.m in Sources */, ED47CB6D28523995004FD755 /* MXCryptoV2.swift in Sources */, 32A1513A1DAD292400400192 /* MXMegolmEncryption.m in Sources */, EC60EDFE265CFFD200B39A4E /* MXInvitedGroupSync.m in Sources */, @@ -6688,6 +6701,7 @@ 324DD2C7246E638B00377005 /* MXAesHmacSha2.m in Sources */, 3A0AF06B2705A11400679D1A /* MXSpaceGraphData.swift in Sources */, 321CFDEF225264C4004D31DF /* NSArray+MatrixSDK.m in Sources */, + ED5C754228B3E80300D24E85 /* MXAnalyticsDestination.swift in Sources */, 918D30B7273951F400A16405 /* MXStoreService.swift in Sources */, 327A5F52239805F600ED6329 /* MXKeyVerificationStart.m in Sources */, 3294FD9D22F321B0007F1E60 /* MXServiceTermsRestClient.m in Sources */, @@ -6712,7 +6726,6 @@ 71DE22E01BC7C51200284153 /* MXReceiptData.m in Sources */, B14766B923D9D9420091F721 /* MXUsersTrustLevelSummary.m in Sources */, 323547D92226D5D600F15F94 /* MXWellKnownBaseConfig.m in Sources */, - 327E37B71A974F75007F026F /* MXLogger.m in Sources */, EC0B94272718E64500B4D440 /* CoreDataContextable.swift in Sources */, 324BE4691E3FADB1008D99D4 /* MXMegolmExportEncryption.m in Sources */, 32A31BBF20D3F2EC005916C7 /* MXFilterObject.m in Sources */, @@ -6724,7 +6737,6 @@ C602B58E1F22A8D700B67D87 /* MXImage.swift in Sources */, B105CD9D261E0B70006EB204 /* MXSpaceChildrenSummary.swift in Sources */, 32A9F8E0244720B10069C65B /* MXThrottler.m in Sources */, - 189CC083265E362600BE1FD8 /* MXLog.swift in Sources */, EC8A53E425B1BCC6004E0802 /* MXThirdPartyUsersResponse.m in Sources */, 3295401A216385F100E300FC /* MXServerNoticeContent.m in Sources */, B19A30A82404257700FB6F35 /* MXSASKeyVerificationStart.m in Sources */, @@ -6732,6 +6744,7 @@ 02CAD439217DD12F0074700B /* MXContentScanResult.m in Sources */, ED2DD116286C450600F06731 /* MXEventDecryptionResult+DecryptedEvent.swift in Sources */, EC60ED9C265CFE1700B39A4E /* MXRoomSyncState.m in Sources */, + ED5C754028B3E80300D24E85 /* MXLog.swift in Sources */, 32133016228AF4EF0070BA9B /* MXRealmAggregationsStore.m in Sources */, B19A30A62404257700FB6F35 /* MXQRCodeKeyVerificationStart.m in Sources */, B146D47B21A5958400D8C2C6 /* MXAntivirusScanStatusFormatter.m in Sources */, @@ -6983,7 +6996,6 @@ B14EF1CC2397E90400758AF0 /* MXEventAnnotationChunk.m in Sources */, B14EF1CD2397E90400758AF0 /* MXRealmEventScanStore.m in Sources */, ECE3DF9E270C660900FB4C96 /* MXMulticastDelegate.swift in Sources */, - 181FD5D72660C791008EC084 /* MXLogObjcWrapper.m in Sources */, EC1165B127107E330089FA56 /* MXRoomListDataManager.swift in Sources */, 324DD2C2246D658500377005 /* MXHkdfSha256.m in Sources */, B16C2450283AB05700F5D1FE /* MXRealmBeacon.swift in Sources */, @@ -7054,6 +7066,7 @@ EC8A53C625B1BC77004E0802 /* MXTurnServerResponse.m in Sources */, B14EF1F02397E90400758AF0 /* MXReplyEventParser.m in Sources */, B14EF1F12397E90400758AF0 /* MXFileStore.m in Sources */, + ED5C754728B3E80300D24E85 /* MXLogger.m in Sources */, B14EF1F22397E90400758AF0 /* MXIdentityService.swift in Sources */, B14EF1F32397E90400758AF0 /* MXServerNotices.m in Sources */, B14EF1F42397E90400758AF0 /* MXMemoryStore.m in Sources */, @@ -7113,6 +7126,7 @@ B14EF2062397E90400758AF0 /* MXGroup.m in Sources */, B14EF2072397E90400758AF0 /* MXAutoDiscovery.m in Sources */, 3297913123AA126500F7BB9B /* MXKeyVerificationStatusResolver.m in Sources */, + ED5C754528B3E80300D24E85 /* MXLogObjcWrapper.m in Sources */, ED47CB6E28523995004FD755 /* MXCryptoV2.swift in Sources */, B14EF2082397E90400758AF0 /* MX3PidAddManager.m in Sources */, ECD2899026EB3B3400F268CF /* MXRoomListData.swift in Sources */, @@ -7281,10 +7295,10 @@ B1EE98C92804697400AB63F0 /* MXBeacon.m in Sources */, B105CD9E261E0B70006EB204 /* MXSpaceChildrenSummary.swift in Sources */, B14EF2552397E90400758AF0 /* MXWellKnownBaseConfig.m in Sources */, - B14EF2562397E90400758AF0 /* MXLogger.m in Sources */, EC383BB425406894002FBBE6 /* MXSyncResponseFileStore.swift in Sources */, B14EF2572397E90400758AF0 /* MXMegolmExportEncryption.m in Sources */, 3A0AF06C2705A11400679D1A /* MXSpaceGraphData.swift in Sources */, + ED5C754328B3E80300D24E85 /* MXAnalyticsDestination.swift in Sources */, 918D30B8273951F400A16405 /* MXStoreService.swift in Sources */, B14EF2582397E90400758AF0 /* MXFilterObject.m in Sources */, EC60EDEB265CFF3100B39A4E /* MXRoomInviteState.m in Sources */, @@ -7329,6 +7343,7 @@ ECCA02BC273485B200B6F34F /* MXThreadingService.swift in Sources */, ED2DD117286C450600F06731 /* MXEventDecryptionResult+DecryptedEvent.swift in Sources */, B14EF2692397E90400758AF0 /* MXMatrixVersions.m in Sources */, + ED5C754128B3E80300D24E85 /* MXLog.swift in Sources */, B14EF26A2397E90400758AF0 /* MXReactionCountChangeListener.m in Sources */, B14EF26B2397E90400758AF0 /* MXMegolmBackupCreationInfo.m in Sources */, B14EF26C2397E90400758AF0 /* MXRoom.m in Sources */, @@ -7400,7 +7415,6 @@ B14EF2872397E90400758AF0 /* MXPusherData.m in Sources */, 324DD2A3246AE1EF00377005 /* MXEncryptedSecretContent.m in Sources */, EC8A53B625B1BC77004E0802 /* MXCallHangupEventContent.m in Sources */, - 189CC084265E362700BE1FD8 /* MXLog.swift in Sources */, B14EF2882397E90400758AF0 /* MXOlmDevice.m in Sources */, B14766BA23D9D9420091F721 /* MXUsersTrustLevelSummary.m in Sources */, B14EF2892397E90400758AF0 /* MXKeyBackupPassword.m in Sources */, diff --git a/MatrixSDK/Aggregations/LocationSharing/MXBeaconAggregations.swift b/MatrixSDK/Aggregations/LocationSharing/MXBeaconAggregations.swift index 943370228f..10d4b8fa24 100644 --- a/MatrixSDK/Aggregations/LocationSharing/MXBeaconAggregations.swift +++ b/MatrixSDK/Aggregations/LocationSharing/MXBeaconAggregations.swift @@ -165,7 +165,7 @@ public class MXBeaconAggregations: NSObject { room.redactEvent(relationEvent.eventId, reason: nil) { response in if case .failure(let error) = response { - MXLog.error("[MXBeaconAggregations] Failed to redact m.beacon event with error: \(error)") + MXLog.error("[MXBeaconAggregations] Failed to redact m.beacon event", context: error) } } } @@ -182,7 +182,7 @@ public class MXBeaconAggregations: NSObject { // Redact stopped beacon info room.redactEvent(eventId, reason: nil) { response in if case .failure(let error) = response { - MXLog.error("[MXBeaconAggregations] Failed to redact stopped m.beacon_info event with error: \(error)") + MXLog.error("[MXBeaconAggregations] Failed to redact stopped m.beacon_info event", context: error) } } } @@ -258,7 +258,9 @@ public class MXBeaconAggregations: NSObject { existingBeaconInfoSummary.updateWithBeaconInfo(beaconInfo) beaconInfoSummary = existingBeaconInfoSummary } else { - MXLog.error("[MXBeaconAggregations] Fails to find beacon info summary associated to stopped beacon info event id: \(eventId)") + MXLog.error("[MXBeaconAggregations] Fails to find beacon info summary associated to stopped beacon info", context: [ + "event_id": eventId + ]) } } else if let existingBeaconInfoSummary = self.getBeaconInfoSummary(withIdentifier: eventId, inRoomWithId: roomId) { diff --git a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift index 1c75c793fe..a67ca8d1d5 100644 --- a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift +++ b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift @@ -80,7 +80,7 @@ public class MXBeaconInfoSummaryRealmStore: NSObject { return realm } catch { - MXLog.error("[MXBeaconInfoSummaryRealmStore] failed to create Realm store with error: \(error)") + MXLog.error("[MXBeaconInfoSummaryRealmStore] failed to create Realm store", context: error) return nil } } @@ -132,7 +132,7 @@ public class MXBeaconInfoSummaryRealmStore: NSObject { do { try FileManager.default.createDirectory(at: realmFileFolderURL, withIntermediateDirectories: true, attributes: nil) } catch { - MXLog.error("[MXBeaconInfoSummaryRealmStore] Fail to create Realm folder \(realmFileFolderURL) with error: \(error)") + MXLog.error("[MXBeaconInfoSummaryRealmStore] Fail to create Realm folder", context: error) throw error } @@ -182,7 +182,7 @@ extension MXBeaconInfoSummaryRealmStore: MXBeaconInfoSummaryStoreProtocol { realm.addOrUpdate(realmBeaconInfoSummary) } } catch { - MXLog.error("[MXBeaconInfoSummaryRealmStore] addOrUpdateBeaconInfoSummary failed with error: \(error)") + MXLog.error("[MXBeaconInfoSummaryRealmStore] addOrUpdateBeaconInfoSummary failed", context: error) } } @@ -289,7 +289,7 @@ extension MXBeaconInfoSummaryRealmStore: MXBeaconInfoSummaryStoreProtocol { realm.deleteObjects(realmBeaconInfoSummaries) } } catch { - MXLog.error("[MXBeaconInfoSummaryRealmStore] deleteAllBeaconInfoSummaries failed with error: \(error)") + MXLog.error("[MXBeaconInfoSummaryRealmStore] deleteAllBeaconInfoSummaries failed", context: error) } } @@ -305,7 +305,7 @@ extension MXBeaconInfoSummaryRealmStore: MXBeaconInfoSummaryStoreProtocol { realm.deleteObjects(realmBeaconInfoSummaries) } } catch { - MXLog.error("[MXBeaconInfoSummaryRealmStore] deleteAllBeaconInfoSummaries failed with error: \(error)") + MXLog.error("[MXBeaconInfoSummaryRealmStore] deleteAllBeaconInfoSummaries failed", context: error) } } @@ -320,7 +320,7 @@ extension MXBeaconInfoSummaryRealmStore: MXBeaconInfoSummaryStoreProtocol { realm.deleteAllObjects() } } catch { - MXLog.error("[MXBeaconInfoSummaryRealmStore] Failed to delete all objects: \(error)") + MXLog.error("[MXBeaconInfoSummaryRealmStore] Failed to delete all objects", context: error) } } } diff --git a/MatrixSDK/Aggregations/MXAggregatedReactionsUpdater.m b/MatrixSDK/Aggregations/MXAggregatedReactionsUpdater.m index 447a6386fd..b07b9669a7 100644 --- a/MatrixSDK/Aggregations/MXAggregatedReactionsUpdater.m +++ b/MatrixSDK/Aggregations/MXAggregatedReactionsUpdater.m @@ -619,7 +619,9 @@ - (MXHTTPOperation*)sendReaction:(NSString*)reaction MXRoom *room = [self.mxSession roomWithRoomId:roomId]; if (!room) { - MXLogError(@"[MXAggregations] sendReaction Error: Unknown room: %@", roomId); + MXLogErrorDetails(@"[MXAggregations] sendReaction Error: Unknown room", @{ + @"room_id": roomId ?: @"unknown" + }); return nil; } diff --git a/MatrixSDK/Background/MXBackgroundSyncService.swift b/MatrixSDK/Background/MXBackgroundSyncService.swift index b1d4ab1899..6d37726144 100644 --- a/MatrixSDK/Background/MXBackgroundSyncService.swift +++ b/MatrixSDK/Background/MXBackgroundSyncService.swift @@ -551,7 +551,10 @@ public enum MXBackgroundSyncServiceError: Error { case .success: MXLog.debug("[MXBackgroundSyncService] handleSyncResponse: Joined room: \(roomId)") case .failure(let error): - MXLog.error("[MXBackgroundSyncService] handleSyncResponse: Failed to join room: \(roomId), error: \(error)") + MXLog.error("[MXBackgroundSyncService] handleSyncResponse: Failed to join room", context: [ + "error": error, + "room_id": roomId + ]) } } } diff --git a/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift b/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift index 49a92f1451..9fafbe4983 100644 --- a/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift +++ b/MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift @@ -72,7 +72,7 @@ class MXCrossSigningV2: MXCrossSigning { success() } } catch { - log.error("Cannot setup cross signing", error: error) + log.error("Cannot setup cross signing", context: error) await MainActor.run { failure(error) } @@ -92,7 +92,7 @@ class MXCrossSigningV2: MXCrossSigning { success() } } catch { - log.error("Cannot setup cross signing", error: error) + log.error("Cannot setup cross signing", context: error) await MainActor.run { failure(error) } diff --git a/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift b/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift index d35546d6be..daef68ccd8 100644 --- a/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift +++ b/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift @@ -235,7 +235,7 @@ extension MXCryptoMachine: MXCryptoDevicesSource { do { return try machine.getUserDevices(userId: userId, timeout: 0) } catch { - log.error("Cannot fetch devices", error: error) + log.error("Cannot fetch devices", context: error) return [] } } @@ -244,7 +244,7 @@ extension MXCryptoMachine: MXCryptoDevicesSource { do { return try machine.getDevice(userId: userId, deviceId: deviceId, timeout: 0) } catch { - log.error("Cannot fetch device", error: error) + log.error("Cannot fetch device", context: error) return nil } } @@ -256,7 +256,7 @@ extension MXCryptoMachine: MXCryptoUserIdentitySource { do { return try machine.isIdentityVerified(userId: userId) } catch { - log.error("Failed checking user verification status", error: error) + log.error("Failed checking user verification status", context: error) return false } } @@ -473,7 +473,9 @@ extension MXCryptoMachine: Logger { } func log(error: String) { - MXLog.error("[MXCryptoMachine] \(error)") + MXLog.error("[MXCryptoMachine] Error", context: [ + "error": error + ]) } } diff --git a/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m b/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m index 402ce6f21b..a302c2ea77 100644 --- a/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m +++ b/MatrixSDK/Crypto/Data/Store/MXRealmCryptoStore/MXRealmCryptoStore.m @@ -408,9 +408,7 @@ + (void)_deleteStoreWithCredentials:(MXCredentials*)credentials readOnly:(BOOL)r [RLMRealm deleteFilesForConfiguration:config error:&error]; if (error) { - MXLogErrorWithDetails(@"[MXRealmCryptoStore] deleteStore error", @{ - @"error": error - }); + MXLogErrorDetails(@"[MXRealmCryptoStore] deleteStore error", error); if (!readOnly) { @@ -427,9 +425,7 @@ + (void)_deleteStoreWithCredentials:(MXCredentials*)credentials readOnly:(BOOL)r } else { - MXLogErrorWithDetails(@"[MXRealmCryptoStore] deleteStore: Cannot open realm.", @{ - @"error": error - }); + MXLogErrorDetails(@"[MXRealmCryptoStore] deleteStore: Cannot open realm.", error); } } } @@ -892,7 +888,7 @@ - (void)performSessionOperationWithDevice:(NSString*)deviceKey andSessionId:(NSS } else { - MXLogErrorWithDetails(@"[MXRealmCryptoStore] performSessionOperationWithDevice. Error: olm session not found", @{ + MXLogErrorDetails(@"[MXRealmCryptoStore] performSessionOperationWithDevice. Error: olm session not found", @{ @"sessionId": sessionId }); block(nil); @@ -1011,7 +1007,7 @@ - (void)performSessionOperationWithGroupSessionWithId:(NSString*)sessionId sende } else { - MXLogErrorWithDetails(@"[MXRealmCryptoStore] performSessionOperationWithGroupSessionWithId. Error: Cannot build MXOlmInboundGroupSession for megolm session", @{ + MXLogErrorDetails(@"[MXRealmCryptoStore] performSessionOperationWithGroupSessionWithId. Error: Cannot build MXOlmInboundGroupSession for megolm session", @{ @"sessionId": sessionId }); block(nil); @@ -1019,7 +1015,7 @@ - (void)performSessionOperationWithGroupSessionWithId:(NSString*)sessionId sende } else { - MXLogErrorWithDetails(@"[MXRealmCryptoStore] performSessionOperationWithGroupSessionWithId. Error: megolm session not found", @{ + MXLogErrorDetails(@"[MXRealmCryptoStore] performSessionOperationWithGroupSessionWithId. Error: megolm session not found", @{ @"sessionId": sessionId }); block(nil); diff --git a/MatrixSDK/Crypto/Dehydration/MXDehydrationService.m b/MatrixSDK/Crypto/Dehydration/MXDehydrationService.m index 948e108f55..17a17bf4d3 100644 --- a/MatrixSDK/Crypto/Dehydration/MXDehydrationService.m +++ b/MatrixSDK/Crypto/Dehydration/MXDehydrationService.m @@ -74,7 +74,9 @@ - (void)dehydrateDeviceWithMatrixRestClient:(MXRestClient*)restClient if (error) { - MXLogError(@"[MXDehydrationService] dehydrateDevice: Account serialization failed: %@", error); + MXLogErrorDetails(@"[MXDehydrationService] dehydrateDevice: Account serialization failed", @{ + @"error": error ?: @"unknown" + }); [self stopProgress]; failure(error); return; @@ -114,7 +116,9 @@ - (void)dehydrateDeviceWithMatrixRestClient:(MXRestClient*)restClient }]; } failure:^(NSError *error) { [self stopProgress]; - MXLogError(@"[MXDehydrationService] dehydrateDevice: Failed pushing dehydrated device data: %@", error); + MXLogErrorDetails(@"[MXDehydrationService] dehydrateDevice: Failed pushing dehydrated device data", @{ + @"error": error ?: @"unknown" + }); failure(error); }]; } @@ -176,7 +180,9 @@ - (void)rehydrateDeviceWithMatrixRestClient:(MXRestClient*)restClient }); }]; } failure:^(NSError *error) { - MXLogError(@"[MXDehydrationService] rehydrateDevice: Claiming dehydrated device failed with error: %@", error); + MXLogErrorDetails(@"[MXDehydrationService] rehydrateDevice: Claiming dehydrated device failed", @{ + @"error": error ?: @"unknown" + }); failure(error); }]; } failure:^(NSError *error) { @@ -193,7 +199,9 @@ - (void)rehydrateDeviceWithMatrixRestClient:(MXRestClient*)restClient } else { - MXLogError(@"[MXDehydrationService] rehydrateDevice: DehydratedDeviceId failed with error: %@", error); + MXLogErrorDetails(@"[MXDehydrationService] rehydrateDevice: DehydratedDeviceId failed", @{ + @"error": error ?: @"unknown" + }); failure(error); } }]; @@ -229,7 +237,9 @@ - (void)uploadDeviceInfo:(MXDeviceInfo*)deviceInfo [self stopProgress]; success(deviceInfo.deviceId); } failure:^(NSError *error) { - MXLogError(@"[MXDehydrationService] uploadDeviceInfo: failed uploading device keys: %@", error); + MXLogErrorDetails(@"[MXDehydrationService] uploadDeviceInfo: failed uploading device keys", @{ + @"error": error ?: @"unknown" + }); MXStrongifyAndReturnIfNil(self); [self stopProgress]; failure(error); diff --git a/MatrixSDK/Crypto/KeyBackup/Data/Aes256/MXAes256KeyBackupAlgorithm.m b/MatrixSDK/Crypto/KeyBackup/Data/Aes256/MXAes256KeyBackupAlgorithm.m index d53471fdb6..456295a178 100644 --- a/MatrixSDK/Crypto/KeyBackup/Data/Aes256/MXAes256KeyBackupAlgorithm.m +++ b/MatrixSDK/Crypto/KeyBackup/Data/Aes256/MXAes256KeyBackupAlgorithm.m @@ -80,7 +80,9 @@ + (MXKeyBackupPreparationInfo *)prepareWith:(NSString*)password error:(NSError * if (*error) { - MXLogError(@"[MXAes256KeyBackupAlgorithm] prepare: error: %@", *error); + MXLogErrorDetails(@"[MXAes256KeyBackupAlgorithm] prepare", @{ + @"error": *error ?: @"unknown" + }); return nil; } diff --git a/MatrixSDK/Crypto/KeyBackup/Data/Curve25519/MXCurve25519KeyBackupAlgorithm.m b/MatrixSDK/Crypto/KeyBackup/Data/Curve25519/MXCurve25519KeyBackupAlgorithm.m index 3c49f01d89..a74a578613 100644 --- a/MatrixSDK/Crypto/KeyBackup/Data/Curve25519/MXCurve25519KeyBackupAlgorithm.m +++ b/MatrixSDK/Crypto/KeyBackup/Data/Curve25519/MXCurve25519KeyBackupAlgorithm.m @@ -88,7 +88,9 @@ + (MXKeyBackupPreparationInfo *)prepareWith:(NSString *)password error:(NSError if (*error) { - MXLogError(@"[MXCurve25519KeyBackupAlgorithm] prepare: error: %@", *error); + MXLogErrorDetails(@"[MXCurve25519KeyBackupAlgorithm] prepare", @{ + @"error": *error ?: @"unknown" + }); return nil; } return [[MXKeyBackupPreparationInfo alloc] initWithPrivateKey:decryption.privateKey authData:authData]; diff --git a/MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m b/MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m index d48f196a2e..0206f7e3a0 100644 --- a/MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m +++ b/MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m @@ -153,7 +153,8 @@ - (void)checkAndStartWithKeyBackupVersion:(nullable MXKeyBackupVersion*)keyBacku Class algorithmClass = AlgorithmClassesByName[keyBackupVersion.algorithm]; if (algorithmClass == NULL) { - MXLogError(@"[MXKeyBackup] checkAndStartWithKeyBackupVersion: unknown algorithm: %@", keyBackupVersion.algorithm); + NSString *message = [NSString stringWithFormat:@"[MXKeyBackup] checkAndStartWithKeyBackupVersion: unknown algorithm: %@", keyBackupVersion.algorithm]; + MXLogError(message); return; } if (![algorithmClass checkBackupVersion:keyBackupVersion]) @@ -1419,7 +1420,8 @@ - (BOOL)canBeRefreshed Class algorithmClass = AlgorithmClassesByName[keyBackupVersion.algorithm]; if (algorithmClass == NULL) { - MXLogError(@"[MXKeyBackup] getOrCreateKeyBackupAlgorithmFor: unknown algorithm: %@", keyBackupVersion.algorithm); + NSString *message = [NSString stringWithFormat:@"[MXKeyBackup] getOrCreateKeyBackupAlgorithmFor: unknown algorithm: %@", keyBackupVersion.algorithm]; + MXLogError(message); return nil; } if (![algorithmClass checkBackupVersion:keyBackupVersion]) @@ -1553,7 +1555,8 @@ - (nullable NSData*)privateKeyFromCryptoStore Class algorithmClass = AlgorithmClassesByName[keyBackupVersion.algorithm]; if (algorithmClass == NULL) { - MXLogError(@"[MXKeyBackup] megolmBackupAuthDataFromKeyBackupVersion: Key backup for unknown algorithm: %@", keyBackupVersion.algorithm); + NSString *message = [NSString stringWithFormat:@"[MXKeyBackup] megolmBackupAuthDataFromKeyBackupVersion: Key backup for unknown algorithm: %@", keyBackupVersion.algorithm]; + MXLogError(message); *error = [NSError errorWithDomain:MXKeyBackupErrorDomain code:MXKeyBackupErrorUnknownAlgorithm diff --git a/MatrixSDK/Crypto/MXCrypto.m b/MatrixSDK/Crypto/MXCrypto.m index 8a9d3fd8e3..a75d1aebeb 100644 --- a/MatrixSDK/Crypto/MXCrypto.m +++ b/MatrixSDK/Crypto/MXCrypto.m @@ -250,7 +250,9 @@ + (void)rehydrateExportedOlmDevice:(MXExportedOlmDevice*)exportedOlmDevice dispatch_async(cryptoQueue, ^{ if ([MXCryptoStoreClass hasDataForCredentials:credentials]) { - MXLogError(@"the exported Olm device with ID %@ shouldn't exist locally", credentials.deviceId); + MXLogErrorDetails(@"the exported Olm device shouldn't exist locally", @{ + @"device_id": credentials.deviceId ?: @"unknown" + }); complete(false); return; } @@ -378,7 +380,9 @@ - (void)start:(void (^)(void))success } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCrypto] start. Error in maybeUploadOneTimeKeys: %@", error); + MXLogErrorDetails(@"[MXCrypto] start. Error in maybeUploadOneTimeKeys", @{ + @"error": error ?: @"unknown" + }); dispatch_async(dispatch_get_main_queue(), ^{ self->startOperation = nil; failure(error); @@ -388,7 +392,9 @@ - (void)start:(void (^)(void))success } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCrypto] start. Error in uploadDeviceKeys: %@", error); + MXLogErrorDetails(@"[MXCrypto] start. Error in uploadDeviceKeys", @{ + @"error": error ?: @"unknown" + }); dispatch_async(dispatch_get_main_queue(), ^{ self->startOperation = nil; failure(error); @@ -548,7 +554,9 @@ - (MXHTTPOperation *)encryptEventContent:(NSDictionary *)eventContent withType:( }); } failure:^(NSError *error) { - MXLogError(@"[MXCrypto] encryptEventContent: Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] encryptEventContent: Error", @{ + @"error": error ?: @"unknown" + }); dispatch_async(dispatch_get_main_queue(), ^{ failure(error); @@ -653,7 +661,12 @@ - (MXEventDecryptionResult *)decryptEvent2:(MXEvent *)event inTimeline:(NSString result = [alg decryptEvent:event inTimeline:timeline]; if (result.error) { - MXLogError(@"[MXCrypto] decryptEvent: Error for %@: %@\nEvent: %@", event.eventId, result.error, event.JSONDictionary); + NSDictionary *details = @{ + @"event_id": event.eventId ?: @"unknown", + @"error": result.error ?: @"unknown", + @"event": event.JSONDictionary ?: @"unknown" + }; + MXLogErrorDetails(@"[MXCrypto] decryptEvent", details); if ([result.error.domain isEqualToString:MXDecryptingErrorDomain] && result.error.code == MXDecryptingErrorBadEncryptedMessageCode) @@ -936,7 +949,9 @@ - (void)onSyncCompleted:(NSString *)oldSyncToken nextSyncToken:(NSString *)nextS } failure:^(NSError *error) { // If that failed, we fall back to invalidating everyone. - MXLogError(@"[MXCrypto] onSyncCompleted: Error fetching changed device list. Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] onSyncCompleted: Error fetching changed device list", @{ + @"error": error ?: @"unknown" + }); [self.deviceList invalidateAllDeviceLists]; }]; } @@ -1670,7 +1685,9 @@ - (void)importRoomKeys:(NSData *)keyFile withPassword:(NSString *)password succe dispatch_async(dispatch_get_main_queue(), ^{ - MXLogError(@"[MXCrypto] importRoomKeys:withPassword: Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] importRoomKeys:withPassword: Error", @{ + @"error": error ?: @"unknown" + }); if (failure) { @@ -1768,7 +1785,11 @@ - (void)acceptKeyRequestFromCryptoThread:(MXIncomingRoomKeyRequest *)keyRequest { dispatch_async(dispatch_get_main_queue(), ^{ - MXLogError(@"[MXCrypto] acceptPendingKeyRequests: ERROR: unknown alg %@ in room %@", alg, roomId); + NSDictionary *details = @{ + @"algorithm": alg ?: @"unknown", + @"room_id": roomId ?: @"unknown", + }; + MXLogErrorDetails(@"[MXCrypto] acceptPendingKeyRequests: ERROR: unknown alg in room", details); if (failure) { failure(nil); @@ -2110,7 +2131,8 @@ - (BOOL)setEncryptionInRoom:(NSString*)roomId withMembers:(NSArray*)m Class encryptionClass = [[MXCryptoAlgorithms sharedAlgorithms] encryptorClassForAlgorithm:algorithm]; if (!encryptionClass) { - MXLogError(@"[MXCrypto] setEncryptionInRoom: Unable to encrypt with %@", algorithm); + NSString *message = [NSString stringWithFormat:@"[MXCrypto] setEncryptionInRoom: Unable to encrypt with %@", algorithm]; + MXLogError(message); return NO; } @@ -2405,12 +2427,18 @@ - (NSString*)verifyKeyAndStartSession:(MXKey*)oneTimeKey userId:(NSString*)userI else { // Possibly a bad key - MXLogError(@"[MXCrypto] verifyKeyAndStartSession: Error starting olm session with device %@:%@", userId, deviceId); + MXLogErrorDetails(@"[MXCrypto] verifyKeyAndStartSession: Error starting olm session with device", @{ + @"device_id": deviceId ?: @"unknown" + }); } } else { - MXLogError(@"[MXCrypto] verifyKeyAndStartSession: Unable to verify signature on one-time key for device %@:%@. Error: %@", userId, deviceId, error.localizedFailureReason); + NSDictionary *details = @{ + @"device_id": deviceId ?: @"unknown", + @"error": error ?: @"unknown" + }; + MXLogErrorDetails(@"[MXCrypto] verifyKeyAndStartSession: Unable to verify signature on one-time key for device", details); } return sessionId; @@ -2695,7 +2723,8 @@ - (void)onRoomKeyEvent:(MXEvent*)event id alg = [self getRoomDecryptor:event.content[@"room_id"] algorithm:event.content[@"algorithm"]]; if (!alg) { - MXLogError(@"[MXCrypto] onRoomKeyEvent: ERROR: Unable to handle keys for %@", event.content[@"algorithm"]); + NSString *message = [NSString stringWithFormat:@"[MXCrypto] onRoomKeyEvent: ERROR: Unable to handle keys for %@", event.content[@"algorithm"]]; + MXLogError(message); return; } @@ -2860,7 +2889,9 @@ - (void)maybeUploadOneTimeKeys:(void (^)(void))success failure:(void (^)(NSError } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCrypto] maybeUploadOneTimeKeys: Failed to publish one-time keys. Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] maybeUploadOneTimeKeys: Failed to publish one-time keys", @{ + @"error": error ?: @"unknown" + }); self->uploadOneTimeKeysOperation = nil; if (failure) @@ -2906,7 +2937,9 @@ - (void)maybeUploadOneTimeKeys:(void (^)(void))success failure:(void (^)(NSError } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCrypto] maybeUploadOneTimeKeys: Failed to publish one-time keys. Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] maybeUploadOneTimeKeys: Failed to publish one-time keys", @{ + @"error": error ?: @"unknown" + }); self->uploadOneTimeKeysOperation = nil; if (failure) @@ -2931,7 +2964,9 @@ - (void)maybeUploadOneTimeKeys:(void (^)(void))success failure:(void (^)(NSError } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCrypto] maybeUploadOneTimeKeys: Get published one-time keys count failed. Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] maybeUploadOneTimeKeys: Get published one-time keys count failed", @{ + @"error": error ?: @"unknown" + }); self->uploadOneTimeKeysOperation = nil; if (failure) @@ -2953,7 +2988,9 @@ - (MXHTTPOperation *)generateAndUploadOneTimeKeys:(NSUInteger)keyCount retry:(BO operation = [self uploadOneTimeKeys:^(MXKeysUploadResponse *keysUploadResponse) { success(); } failure:^(NSError *error) { - MXLogError(@"[MXCrypto] generateAndUploadOneTimeKeys: Failed to publish one-time keys. Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] generateAndUploadOneTimeKeys: Failed to publish one-time keys", @{ + @"error": error ?: @"unknown" + }); if ([MXError isMXError:error] && retry) { @@ -3113,7 +3150,9 @@ - (MXHTTPOperation *)publishedOneTimeKeysCount:(void (^)(NSUInteger publishedKey success(publishedkeyCount); } failure:^(NSError *error) { - MXLogError(@"[MXCrypto] publishedOneTimeKeysCount failed. Error: %@", error); + MXLogErrorDetails(@"[MXCrypto] publishedOneTimeKeysCount failed", @{ + @"error": error ?: @"unknown" + }); failure(error); }]; } @@ -3189,7 +3228,9 @@ - (void)markOlmSessionForUnwedgingInEvent:(MXEvent*)event }]; } failure:^(NSError *error) { - MXLogError(@"[MXCrypto] markOlmSessionForUnwedgingInEvent: ERROR for ensureOlmSessionsForDevices: %@", error); + MXLogErrorDetails(@"[MXCrypto] markOlmSessionForUnwedgingInEvent: ERROR for ensureOlmSessionsForDevices", @{ + @"error": error ?: @"unknown" + }); }]; } diff --git a/MatrixSDK/Crypto/MXCryptoV2.swift b/MatrixSDK/Crypto/MXCryptoV2.swift index 693ac84885..e9f02f3ace 100644 --- a/MatrixSDK/Crypto/MXCryptoV2.swift +++ b/MatrixSDK/Crypto/MXCryptoV2.swift @@ -48,7 +48,7 @@ public extension MXCrypto { do { return try MXCryptoV2(userId: userId, deviceId: deviceId, session: session, restClient: restClient) } catch { - log.failure("Error creating crypto V2", error: error) + log.failure("Error creating crypto V2", context: error) return nil } #else @@ -234,7 +234,7 @@ private class MXCryptoV2: MXCrypto { success?(result, kMXEventTypeStringRoomEncrypted) } } catch { - log.error("Error encrypting content", error: error) + log.error("Error encrypting content", context: error) await MainActor.run { failure?(error) } @@ -258,7 +258,7 @@ private class MXCryptoV2: MXCrypto { return result } catch { - log.error("Error decrypting event", error: error) + log.error("Error decrypting event", context: error) let result = MXEventDecryptionResult() result.error = error return result @@ -294,7 +294,7 @@ private class MXCryptoV2: MXCrypto { success?() } } catch { - log.error("Error ensuring encryption", error: error) + log.error("Error ensuring encryption", context: error) await MainActor.run { failure?(error) } @@ -324,7 +324,7 @@ private class MXCryptoV2: MXCrypto { unusedFallbackKeys: syncResponse.unusedFallbackKeys ) } catch { - log.error("Cannot handle sync", error: error) + log.error("Cannot handle sync", context: error) } } @@ -349,7 +349,7 @@ private class MXCryptoV2: MXCrypto { do { try await machine.completeSync() } catch { - log.failure("Error processing outgoing requests", error: error) + log.failure("Error processing outgoing requests", context: error) } } keyVerification.updatePendingRequests() @@ -480,7 +480,7 @@ private class MXCryptoV2: MXCrypto { do { try machine.deleteAllData() } catch { - log.failure("Cannot delete crypto store", error: error) + log.failure("Cannot delete crypto store", context: error) } onComplete?() } diff --git a/MatrixSDK/Crypto/Verification/MXKeyVerificationManager.m b/MatrixSDK/Crypto/Verification/MXKeyVerificationManager.m index e200b96ca2..f4b0bcd98f 100644 --- a/MatrixSDK/Crypto/Verification/MXKeyVerificationManager.m +++ b/MatrixSDK/Crypto/Verification/MXKeyVerificationManager.m @@ -777,7 +777,8 @@ - (void)cancelTransaction:(id)transaction } else { - MXLogFailure(@"[MXKeyVerification] cancelTransaction: Cannot set cancellation reason on unknown transaction type: %@", NSStringFromClass([transaction class])) + NSString *message = [NSString stringWithFormat:@"[MXKeyVerification] cancelTransaction: Cannot set cancellation reason on unknown transaction type: %@", NSStringFromClass([transaction class])]; + MXLogFailure(message) } if (success) diff --git a/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift b/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift index 0f13d14365..263b69ee1b 100644 --- a/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift +++ b/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift @@ -100,7 +100,7 @@ class MXKeyVerificationManagerV2: MXKeyVerificationManager { success(request) } } catch { - log.error("Cannot request verification", error: error) + log.error("Cannot request verification", context: error) await MainActor.run { failure(error) } @@ -150,7 +150,7 @@ class MXKeyVerificationManagerV2: MXKeyVerificationManager { success(transaction) } } catch { - MXLog.error("[MXKeyVerificationRequestV2] error \(error)") + MXLog.error("[MXKeyVerificationRequestV2] error", context: error) await MainActor.run { failure(error) } @@ -199,7 +199,7 @@ class MXKeyVerificationManagerV2: MXKeyVerificationManager { idx < emojis.count ? emojis[idx] : nil } } catch { - log.error("Cannot get emoji indices", error: error) + log.error("Cannot get emoji indices", context: error) return [] } } @@ -209,7 +209,7 @@ class MXKeyVerificationManagerV2: MXKeyVerificationManager { do { try await verification.cancelVerification(userId: request.otherUser, flowId: request.requestId, cancelCode: code.value) } catch { - log.error("Cannot cancel request", error: error) + log.error("Cannot cancel request", context: error) } } } @@ -219,7 +219,7 @@ class MXKeyVerificationManagerV2: MXKeyVerificationManager { do { try await verification.confirmVerification(userId: transaction.otherUserId, flowId: transaction.transactionId) } catch { - log.error("Cannot confirm transaction", error: error) + log.error("Cannot confirm transaction", context: error) } } } @@ -229,7 +229,7 @@ class MXKeyVerificationManagerV2: MXKeyVerificationManager { do { try await verification.cancelVerification(userId: transaction.otherUserId, flowId: transaction.transactionId, cancelCode: code.value) } catch { - log.error("Cannot cancel request", error: error) + log.error("Cannot cancel request", context: error) } } } diff --git a/MatrixSDK/Data/EventTimeline/Room/MXRoomEventTimeline.m b/MatrixSDK/Data/EventTimeline/Room/MXRoomEventTimeline.m index 0e33eeeb50..03f3373da7 100644 --- a/MatrixSDK/Data/EventTimeline/Room/MXRoomEventTimeline.m +++ b/MatrixSDK/Data/EventTimeline/Room/MXRoomEventTimeline.m @@ -823,7 +823,9 @@ - (void)handleRedaction:(MXEvent*)redactionEvent self->httpOperation = nil; - MXLogError(@"[MXRoomEventTimeline] handleRedaction: failed to retrieve the redacted event: %@", error); + MXLogErrorDetails(@"[MXRoomEventTimeline] handleRedaction: failed to retrieve the redacted event", @{ + @"error": error ?: @"unknown" + }); }]; } } diff --git a/MatrixSDK/Data/EventTimeline/Thread/MXThreadEventTimeline.swift b/MatrixSDK/Data/EventTimeline/Thread/MXThreadEventTimeline.swift index 00cece42d3..b5fada9a90 100644 --- a/MatrixSDK/Data/EventTimeline/Thread/MXThreadEventTimeline.swift +++ b/MatrixSDK/Data/EventTimeline/Thread/MXThreadEventTimeline.swift @@ -203,7 +203,10 @@ public class MXThreadEventTimeline: NSObject, MXEventTimeline { if eventFound { success() } else if let paginationError = paginationError { - MXLog.error("[MXThreadEventTimeline][\(self.timelineId)] resetPaginationAroundInitialEvent failed: \(paginationError)") + MXLog.error("[MXThreadEventTimeline] resetPaginationAroundInitialEvent failed", context: [ + "error": paginationError, + "timeline_id": self.timelineId + ]) failure(paginationError) } else { failure(MXThreadEventTimelineError.initialEventNotFound) diff --git a/MatrixSDK/Data/MXRoom.m b/MatrixSDK/Data/MXRoom.m index fa8ab83c76..718dea2166 100644 --- a/MatrixSDK/Data/MXRoom.m +++ b/MatrixSDK/Data/MXRoom.m @@ -2827,7 +2827,9 @@ - (void)removeAllOutgoingMessages [self.summary resetLastMessage:nil failure:nil commit:YES]; } } failure:^(NSError *error) { - MXLogError(@"[MXRoom] removeAllOutgoingMessages: event fetch failed: %@", error); + MXLogErrorDetails(@"[MXRoom] removeAllOutgoingMessages: event fetch failed", @{ + @"error": error ?: @"unknown" + }); }]; } @@ -3646,7 +3648,9 @@ - (void)validateEncryptionStateConsistency BOOL isEncryptedInStore = [crypto isRoomEncrypted:self.roomId]; if (isEncryptedInStore && !self.summary.isEncrypted) { - MXLogError(@"[MXRoom] checkEncryptionState: summary.isEncrypted is wrong for room %@. Fix it.", self.roomId); + MXLogErrorDetails(@"[MXRoom] checkEncryptionState: summary.isEncrypted is wrong for room Fix it.", @{ + @"room_id": self.roomId ?: @"unknown" + }); self.summary.isEncrypted = YES; [self.summary save:YES]; } diff --git a/MatrixSDK/Data/MXRoomState.m b/MatrixSDK/Data/MXRoomState.m index c33256d2e1..0147788f7c 100644 --- a/MatrixSDK/Data/MXRoomState.m +++ b/MatrixSDK/Data/MXRoomState.m @@ -129,7 +129,11 @@ + (void)loadRoomStateFromStore:(id)store [roomState handleStateEvents:events]; onComplete(roomState); } failure:^(NSError *error) { - MXLogError(@"[MXRoomState] loadRoomStateFromStore(%@): Failed to load any events from api with error %@", logId, error); + NSDictionary *details = @{ + @"log_id": logId ?: @"unknown", + @"error": error ?: @"unknown" + }; + MXLogErrorDetails(@"[MXRoomState] loadRoomStateFromStore: Failed to load any events from api", details); onComplete(roomState); }]; diff --git a/MatrixSDK/Data/MXRoomSummary.m b/MatrixSDK/Data/MXRoomSummary.m index d3155ea5ca..94ed030a4e 100644 --- a/MatrixSDK/Data/MXRoomSummary.m +++ b/MatrixSDK/Data/MXRoomSummary.m @@ -505,7 +505,9 @@ - (void)registerEventEditsListener MXEvent *editedEvent = [event editedEventFromReplacementEvent:replaceEvent]; [self handleEvent:editedEvent]; } failure:^(NSError *error) { - MXLogError(@"[MXRoomSummary] registerEventEditsListener: event fetch failed: %@", error); + MXLogErrorDetails(@"[MXRoomSummary] registerEventEditsListener: event fetch failed", @{ + @"error": error ?: @"unknown" + }); }]; } }]; @@ -552,7 +554,9 @@ - (void)setIsEncrypted:(BOOL)isEncrypted // This should never happen if (_isEncrypted && !isEncrypted) { - MXLogError(@"[MXRoomSummary] setIsEncrypted: Attempt to reset isEncrypted for room %@. Ignote it. Call stack: %@", self.roomId, [NSThread callStackSymbols]); + MXLogErrorDetails(@"[MXRoomSummary] setIsEncrypted: Attempt to reset isEncrypted for room. Ignote it", @{ + @"room_id": self.roomId ?: @"unknown" + }); return; } diff --git a/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift b/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift index 5eb125128b..3e27255c9a 100644 --- a/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift +++ b/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift @@ -206,7 +206,7 @@ internal class MXSuggestedRoomListDataFetcher: NSObject, MXRoomListDataFetcher { self.computeData(from: summary.childInfos) } case .failure(let error): - MXLog.error("[MXSuggestedRoomListDataFetcher] fetchSpaceChildren failed: \(error)") + MXLog.error("[MXSuggestedRoomListDataFetcher] fetchSpaceChildren failed", context: error) } } } diff --git a/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift b/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift index c5b0189e6c..0a3edf50ae 100644 --- a/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift +++ b/MatrixSDK/Data/RoomList/CoreData/MXCoreDataRoomListDataFetcher.swift @@ -72,7 +72,7 @@ internal class MXCoreDataRoomListDataFetcher: NSObject, MXRoomListDataFetcher { do { return try store.mainManagedObjectContext.count(for: request) } catch let error { - MXLog.error("[MXCoreDataRoomListDataFetcher] failed to count rooms: \(error)") + MXLog.error("[MXCoreDataRoomListDataFetcher] failed to count rooms", context: error) return 0 } } @@ -108,7 +108,7 @@ internal class MXCoreDataRoomListDataFetcher: NSObject, MXRoomListDataFetcher { total: nil) } } catch let error { - MXLog.error("[MXCoreDataRoomListDataFetcher] failed to calculate total counts: \(error)") + MXLog.error("[MXCoreDataRoomListDataFetcher] failed to calculate total counts", context: error) } return result } @@ -197,7 +197,7 @@ internal class MXCoreDataRoomListDataFetcher: NSObject, MXRoomListDataFetcher { try fetchedResultsController.performFetch() computeData() } catch let error { - MXLog.error("[MXCoreDataRoomListDataFetcher] failed to perform fetch: \(error)") + MXLog.error("[MXCoreDataRoomListDataFetcher] failed to perform fetch", context: error) } } diff --git a/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataFetcher.swift b/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataFetcher.swift index b6df59ff4d..9cdefcfd87 100644 --- a/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataFetcher.swift +++ b/MatrixSDK/Data/RoomList/MXStore/MXStoreRoomListDataFetcher.swift @@ -222,7 +222,9 @@ internal class MXStoreRoomListDataFetcher: NSObject, MXRoomListDataFetcher { return } guard let summary = self.store.summary(ofRoom: roomId) else { - MXLog.error("[MXStoreRoomListDataManager] roomAdded: room with id: \(roomId) not found in the store") + MXLog.error("[MXStoreRoomListDataManager] roomAdded: room not found in the store", context: [ + "room_id": roomId + ]) return } self.roomSummaries[roomId] = summary diff --git a/MatrixSDK/Data/RoomSummaryStore/CoreData/MXCoreDataRoomSummaryStore.swift b/MatrixSDK/Data/RoomSummaryStore/CoreData/MXCoreDataRoomSummaryStore.swift index 04c88494fb..25a2c959e6 100644 --- a/MatrixSDK/Data/RoomSummaryStore/CoreData/MXCoreDataRoomSummaryStore.swift +++ b/MatrixSDK/Data/RoomSummaryStore/CoreData/MXCoreDataRoomSummaryStore.swift @@ -111,7 +111,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { do { result = try moc.count(for: request) } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] countRooms failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] countRooms failed", context: error) } } return result @@ -137,7 +137,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { result = dictionaries.compactMap({ $0[propertyName] as? String }) } } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] fetchRoomIds failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] fetchRoomIds failed", context: error) } } return result @@ -156,7 +156,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { result = MXRoomSummary(summaryModel: model) } } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] fetchSummary failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] fetchSummary failed", context: error) } } return result @@ -172,7 +172,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { let results = try moc.fetch(request) return results.first } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] fetchSummary failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] fetchSummary failed", context: error) } return nil } @@ -189,7 +189,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { do { try moc.obtainPermanentIDs(for: [model]) } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] saveSummary couldn't obtain permanent id: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] saveSummary couldn't obtain permanent id", context: error) } } @@ -231,7 +231,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { self.saveIfNeeded(moc) } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] deleteAllSummaries failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] deleteAllSummaries failed", context: error) } } } @@ -250,7 +250,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { completion(mapped) } } catch { - MXLog.error("[MXCoreDataRoomSummaryStore] fetchRoomIds failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] fetchRoomIds failed", context: error) } } } @@ -267,7 +267,7 @@ public class MXCoreDataRoomSummaryStore: NSObject { saved = true } catch { moc.rollback() - MXLog.error("[MXCoreDataRoomSummaryStore] saveIfNeeded failed: \(error)") + MXLog.error("[MXCoreDataRoomSummaryStore] saveIfNeeded failed", context: error) } if saved { diff --git a/MatrixSDK/Data/RoomSummaryStore/CoreData/Models/MXRoomSummaryMO.swift b/MatrixSDK/Data/RoomSummaryStore/CoreData/Models/MXRoomSummaryMO.swift index a12b759756..c886d433a9 100644 --- a/MatrixSDK/Data/RoomSummaryStore/CoreData/Models/MXRoomSummaryMO.swift +++ b/MatrixSDK/Data/RoomSummaryStore/CoreData/Models/MXRoomSummaryMO.swift @@ -117,7 +117,7 @@ public class MXRoomSummaryMO: NSManagedObject { do { try moc.obtainPermanentIDs(for: [membersCountModel]) } catch { - MXLog.error("[MXRoomSummaryMO] update: couldn't obtain permanent id for membersCount: \(error)") + MXLog.error("[MXRoomSummaryMO] update: couldn't obtain permanent id for membersCount", context: error) } s_membersCount = membersCountModel @@ -127,7 +127,7 @@ public class MXRoomSummaryMO: NSManagedObject { do { try moc.obtainPermanentIDs(for: [trustModel]) } catch { - MXLog.error("[MXRoomSummaryMO] update: couldn't obtain permanent id for trust: \(error)") + MXLog.error("[MXRoomSummaryMO] update: couldn't obtain permanent id for trust", context: error) } s_trust = trustModel } else { @@ -143,7 +143,7 @@ public class MXRoomSummaryMO: NSManagedObject { do { try moc.obtainPermanentIDs(for: [lastMessageModel]) } catch { - MXLog.error("[MXRoomSummaryMO] update: couldn't obtain permanent id for lastMessage: \(error)") + MXLog.error("[MXRoomSummaryMO] update: couldn't obtain permanent id for lastMessage", context: error) } s_lastMessage = lastMessageModel } else { diff --git a/MatrixSDK/Data/RoomSummaryStore/File/MXFileRoomSummaryStore.m b/MatrixSDK/Data/RoomSummaryStore/File/MXFileRoomSummaryStore.m index 65cc07013e..36e6a2cd02 100644 --- a/MatrixSDK/Data/RoomSummaryStore/File/MXFileRoomSummaryStore.m +++ b/MatrixSDK/Data/RoomSummaryStore/File/MXFileRoomSummaryStore.m @@ -132,7 +132,11 @@ - (void)storeSummary:(id)summary } @catch(NSException *exception) { - MXLogError(@"[MXFileStore] Warning: room summary file for room %@ has been corrupted. Exception: %@", roomId, exception); + NSDictionary *details = @{ + @"room_id": roomId ?: @"unknown", + @"exception": exception ?: @"unknown" + }; + MXLogErrorDetails(@"[MXFileStore] Warning: room summary file for room has been corrupted", details); } } } diff --git a/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m b/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m index 325e22bf6e..9140a89186 100644 --- a/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m +++ b/MatrixSDK/Data/Store/MXFileStore/MXFileStore.m @@ -903,10 +903,10 @@ - (MXMemoryRoomStore*)getOrCreateRoomStore:(NSString*)roomId @catch (NSException *exception) { NSDictionary *logDetails = @{ - @"roomId": roomId ?: @"", - @"exception": exception + @"roomId": roomId ?: @"unknown", + @"exception": exception ?: @"unknown" }; - MXLogErrorWithDetails(@"[MXFileStore] Warning: MXFileRoomStore file for room has been corrupted", logDetails); + MXLogErrorDetails(@"[MXFileStore] Warning: MXFileRoomStore file for room has been corrupted", logDetails); [self logFiles]; [self deleteAllData]; } @@ -946,10 +946,10 @@ - (MXMemoryRoomOutgoingMessagesStore *)getOrCreateRoomOutgoingMessagesStore:(NSS @catch (NSException *exception) { NSDictionary *logDetails = @{ - @"roomId": roomId ?: @"", - @"exception": exception + @"roomId": roomId ?: @"unknown", + @"exception": exception ?: @"unknown" }; - MXLogErrorWithDetails(@"[MXFileStore] Warning: MXFileRoomOutgoingMessagesStore file for room as been corrupted", logDetails); + MXLogErrorDetails(@"[MXFileStore] Warning: MXFileRoomOutgoingMessagesStore file for room as been corrupted", logDetails); [self logFiles]; [self deleteAllData]; } @@ -993,7 +993,7 @@ - (RoomReceiptsStore*)getOrCreateRoomReceiptsStore:(NSString *)roomId @"roomId": roomId ?: @"", @"exception": exception }; - MXLogErrorWithDetails(@"[MXFileStore] Warning: loadReceipts file for room as been corrupted", logDetails); + MXLogErrorDetails(@"[MXFileStore] Warning: loadReceipts file for room as been corrupted", logDetails); // We used to reset the store and force a full initial sync but this makes the app // start very slowly. @@ -2233,7 +2233,7 @@ - (void)saveObject:(id)object toFile:(NSString *)file NSData *data = [NSKeyedArchiver archivedDataWithRootObject:object requiringSecureCoding:NO error:&error]; if (error) { - MXLogFailure(@"[MXFileStore] Failed archiving root object with error: '%@'", error.debugDescription); + MXLogFailureDetails(@"[MXFileStore] Failed archiving root object", error); return; } @@ -2244,7 +2244,7 @@ - (void)saveObject:(id)object toFile:(NSString *)file } else { - MXLogFailure(@"[MXFileStore] Failed saving data with error: '%@'", error.debugDescription); + MXLogFailureDetails(@"[MXFileStore] Failed saving data", error); } } else @@ -2279,7 +2279,7 @@ - (id)loadObjectOfClasses:(NSSet *)classes fromFile:(NSString *)file } else { - MXLogFailure(@"[MXFileStore] Failed loading object from class with error: '%@'", error.debugDescription); + MXLogFailureDetails(@"[MXFileStore] Failed loading object from class", error); return nil; } } @@ -2311,7 +2311,7 @@ - (id)loadRootObjectWithoutSecureCodingFromFile:(NSString *)file NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data error:&error]; if (error && !unarchiver) { - MXLogFailure(@"[MXFileStore] Cannot create unarchiver with error: '%@'", error.debugDescription); + MXLogFailureDetails(@"[MXFileStore] Cannot create unarchiver", error); return nil; } unarchiver.requiresSecureCoding = NO; @@ -2324,7 +2324,7 @@ - (id)loadRootObjectWithoutSecureCodingFromFile:(NSString *)file } else { - MXLogFailure(@"[MXFileStore] Failed loading object from class with error: '%@'", error.debugDescription); + MXLogFailureDetails(@"[MXFileStore] Failed loading object from class", error); return nil; } } diff --git a/MatrixSDK/HomeServer/MXHomeServerCapabilitiesService.swift b/MatrixSDK/HomeServer/MXHomeServerCapabilitiesService.swift index a12ca52681..51b7ebd638 100644 --- a/MatrixSDK/HomeServer/MXHomeServerCapabilitiesService.swift +++ b/MatrixSDK/HomeServer/MXHomeServerCapabilitiesService.swift @@ -71,7 +71,7 @@ public class MXHomeserverCapabilitiesService: NSObject { case .success(let capabilities): self.capabilities = capabilities case .failure(let error): - MXLog.error("[MXHomeServerCapabilitiesService] update: failed due to error: \(error)") + MXLog.error("[MXHomeServerCapabilitiesService] update: failed", context: error) } self.currentRequest = nil diff --git a/MatrixSDK/MXRestClient.m b/MatrixSDK/MXRestClient.m index 8cbdca00e6..d558770185 100644 --- a/MatrixSDK/MXRestClient.m +++ b/MatrixSDK/MXRestClient.m @@ -255,7 +255,9 @@ -(id)initWithCredentials:(MXCredentials*)inCredentials // If refreshDispatchGroup is unmatched(a request for a new access token is in-flight) wait. dispatch_group_wait([MXRestClient refreshDispatchGroup], DISPATCH_TIME_FOREVER); if(!weakself.completionQueue) { - MXLogError(@"[MXRestClient] tokenProviderHandler: %@ Client closed, exit tokenProviderHandler early", logId); + MXLogErrorDetails(@"[MXRestClient] tokenProviderHandler: Client closed, exit tokenProviderHandler early", @{ + @"log_id": logId ?: @"unknown" + }); return; } MXLogDebug(@"[MXRestClient] tokenProviderHandler: %@ Wait finished", logId); diff --git a/MatrixSDK/MXSession.m b/MatrixSDK/MXSession.m index 15b602e47e..550282d7d2 100644 --- a/MatrixSDK/MXSession.m +++ b/MatrixSDK/MXSession.m @@ -583,7 +583,9 @@ - (void)handleSyncResponse:(MXSyncResponse *)syncResponse dispatch_group_leave(dispatchGroup); } } failure:^(NSError *error) { - MXLogError(@"[MXSession] handleSyncResponse: event fetch failed: %@", error); + MXLogErrorDetails(@"[MXSession] handleSyncResponse: event fetch failed", @{ + @"error": error ?: @"unknown" + }); dispatch_group_leave(dispatchGroup); }]; } @@ -862,7 +864,9 @@ - (void)startWithSyncFilterId:(NSString *)syncFilterId onServerSyncDone:(void (^ } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXSession] startWithSyncFilterId: setStore failed with error: %@", error); + MXLogErrorDetails(@"[MXSession] startWithSyncFilterId: setStore failed", @{ + @"error": error ?: @"unknown" + }); [self setState:MXSessionStateInitialSyncFailed]; failure(error); @@ -951,7 +955,9 @@ - (void)_startWithSyncFilterId:(NSString *)syncFilterId onServerSyncDone:(void ( // Initial server sync [self serverSyncWithServerTimeout:0 success:onServerSyncDone failure:^(NSError *error) { - MXLogError(@"[MXSession] _startWithSyncFilterId: Failed with error %@", error); + MXLogErrorDetails(@"[MXSession] _startWithSyncFilterId: Failed", @{ + @"error": error ?: @"unknown" + }); [self setState:MXSessionStateInitialSyncFailed]; failure(error); @@ -960,7 +966,9 @@ - (void)_startWithSyncFilterId:(NSString *)syncFilterId onServerSyncDone:(void ( } failure:^(NSError *error) { - MXLogError(@"[MXSession] Crypto failed to start. Error: %@", error); + MXLogErrorDetails(@"[MXSession] Crypto failed to start", @{ + @"error": error ?: @"unknown" + }); [self setState:MXSessionStateInitialSyncFailed]; failure(error); @@ -969,7 +977,9 @@ - (void)_startWithSyncFilterId:(NSString *)syncFilterId onServerSyncDone:(void ( } failure:^(NSError *error) { - MXLogError(@"[MXSession] Get the user's profile information failed with error %@", error); + MXLogErrorDetails(@"[MXSession] Get the user's profile information failed", @{ + @"error": error ?: @"unknown" + }); [self setState:MXSessionStateInitialSyncFailed]; failure(error); @@ -1663,7 +1673,9 @@ - (void)handleServerSyncError:(NSError*)error forRequestWithServerTimeout:(NSUIn } else { - MXLogError(@"[MXSession] handleServerSyncError: %@", error); + MXLogErrorDetails(@"[MXSession] handleServerSyncError", @{ + @"error": error ?: @"unknown" + }); MXError *mxError = [[MXError alloc] initWithNSError:error]; if (mxError) @@ -1891,7 +1903,9 @@ - (void)validateAccountData NSInteger keysCount = self.crypto.secretStorage.numberOfValidKeys; if (keysCount > 1) { - MXLogError(@"[MXSession] validateAccountData: Detected %ld valid SSSS keys, should only have one at most", keysCount) + MXLogErrorDetails(@"[MXSession] validateAccountData: Detected multiple valid SSSS keys, should only have one at most", @{ + @"count": @(keysCount) + }); } } @@ -2006,7 +2020,8 @@ - (void)handleBackgroundSyncCacheIfRequiredWithCompletion:(void (^)(void))comple { BOOL isInValidState = _state == MXSessionStateStoreDataReady || _state == MXSessionStatePaused; if (!isInValidState) { - MXLogFailure(@"[MXSession] state %@ is not valid to handle background sync cache, investigate why the method was called", [MXTools readableSessionState:_state]); + NSString *message = [NSString stringWithFormat:@"[MXSession] state %@ is not valid to handle background sync cache, investigate why the method was called", [MXTools readableSessionState:_state]]; + MXLogFailure(message); if (completion) { completion(); @@ -2597,7 +2612,11 @@ - (void)joinPendingRoomInvites [self joinRoom:roomId viaServers:nil success:^(MXRoom *room) { MXLogDebug(@"[MXSession] joinPendingRoomInvites: Joined room: %@", roomId) } failure:^(NSError *error) { - MXLogError(@"[MXSession] joinPendingRoomInvites: Failed to join room: %@, error: %@", roomId, error) + NSDictionary *details = @{ + @"error": error ?: @"unknown", + @"room_id": roomId ?: @"unknown" + }; + MXLogErrorDetails(@"[MXSession] joinPendingRoomInvites: Failed to join room", details); if (error.code == kMXRoomAlreadyJoinedErrorCode) { @@ -3039,7 +3058,7 @@ - (MXHTTPOperation*)eventWithEventId:(NSString*)eventId { if (eventId == nil) { - MXLogError(@"[MXSession] eventWithEventId called with no eventId. Call stack: %@", [NSThread callStackSymbols]); + MXLogError(@"[MXSession] eventWithEventId called with no eventId"); if (failure) { MXError *error = [[MXError alloc] initWithErrorCode:kMXErrCodeStringNotFound @@ -3225,7 +3244,9 @@ - (void)fixRoomsSummariesLastMessageWithMaxServerPaginationCount:(NSUInteger)max } } failure:^(NSError *error) { - MXLogError(@"[MXSession] fixRoomsSummariesLastMessage: event fetch failed: %@", error); + MXLogErrorDetails(@"[MXSession] fixRoomsSummariesLastMessage: event fetch failed", @{ + @"error": error ?: @"unknown" + }); dispatch_group_leave(dispatchGroup); }]; } @@ -4456,12 +4477,16 @@ - (void)prepareIdentityServiceForTermsWithDefault:(NSString *)defaultIdentitySer } failure:^(NSError *error) { // Something went wrong setting the account data identity service - MXLogError(@"[MXSession] Error preparing identity server terms: %@", error); + MXLogErrorDetails(@"[MXSession] Error preparing identity server terms", @{ + @"error": error ?: @"unknown" + }); failure(error); }]; } failure:^(NSError * _Nonnull error) { // Something went wrong getting the identity service's access token. - MXLogError(@"[MXSession] Error preparing identity server terms: %@", error); + MXLogErrorDetails(@"[MXSession] Error preparing identity server terms", @{ + @"error": error ?: @"unknown" + }); failure(error); }]; } @@ -4846,7 +4871,9 @@ - (void)onDidDecryptEvent:(NSNotification *)notification [summary resetLastMessage:nil failure:nil commit:YES]; } } failure:^(NSError *error) { - MXLogError(@"[MXSession] onDidDecryptEvent: event fetch failed: %@", error); + MXLogErrorDetails(@"[MXSession] onDidDecryptEvent: event fetch failed", @{ + @"error": error ?: @"unknown" + }); }]; } } diff --git a/MatrixSDK/Space/MXSpaceFileStore.swift b/MatrixSDK/Space/MXSpaceFileStore.swift index b936371820..ef9c9c2470 100644 --- a/MatrixSDK/Space/MXSpaceFileStore.swift +++ b/MatrixSDK/Space/MXSpaceFileStore.swift @@ -61,7 +61,7 @@ class MXSpaceFileStore: MXSpaceStore { } try FileManager.default.moveItem(at: fileUrl, to: backupUrl) } catch { - MXLog.error("[MXSpaceFileStore] store: storeSpaceGraphData failed to move graph to backup: \(error)") + MXLog.error("[MXSpaceFileStore] store: storeSpaceGraphData failed to move graph to backup", context: error) } } @@ -111,7 +111,7 @@ class MXSpaceFileStore: MXSpaceStore { try FileManager.default.createDirectoryExcludedFromBackup(at: storeUrl) self.storeUrl = storeUrl } catch { - MXLog.error("[MXSpaceStore] setUpStoragePaths was unable to create space storage folder: \(error)") + MXLog.error("[MXSpaceStore] setUpStoragePaths was unable to create space storage folder", context: error) } } else { self.storeUrl = storeUrl diff --git a/MatrixSDK/Space/MXSpaceGraphData.swift b/MatrixSDK/Space/MXSpaceGraphData.swift index 8baa0079dd..f4a7c4ab0b 100644 --- a/MatrixSDK/Space/MXSpaceGraphData.swift +++ b/MatrixSDK/Space/MXSpaceGraphData.swift @@ -122,31 +122,31 @@ class MXSpaceGraphData: NSObject, NSCoding { class func model(fromJSON dictionary: [AnyHashable : Any]!) -> MXSpaceGraphData? { guard let spaceIdsJson = dictionary[Constants.spaceRoomIdsKey] as? [String] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.spaceRoomIdsKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing spaceRoomIdsKey") return nil } guard let parentIdsPerRoomIdJson = dictionary[Constants.parentIdsPerRoomIdKey] as? [String : [String]] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.parentIdsPerRoomIdKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing parentIdsPerRoomIdKey") return nil } guard let ancestorsPerRoomIdJson = dictionary[Constants.ancestorsPerRoomIdKey] as? [String : [String]] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.ancestorsPerRoomIdKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing ancestorsPerRoomIdKey") return nil } guard let descendantsPerRoomIdJson = dictionary[Constants.descendantsPerRoomIdKey] as? [String : [String]] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.descendantsPerRoomIdKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing descendantsPerRoomIdKey") return nil } guard let rootSpaceIdsJson = dictionary[Constants.rootSpaceIdsKey] as? [String] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.rootSpaceIdsKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing rootSpaceIdsKey") return nil } guard let orphanedRoomIdsJson = dictionary[Constants.orphanedRoomIdsKey] as? [String] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.orphanedRoomIdsKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing orphanedRoomIdsKey") return nil } guard let orphanedDirectRoomIdsJson = dictionary[Constants.orphanedDirectRoomIdsKey] as? [String] else { - MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing \(Constants.orphanedDirectRoomIdsKey)") + MXLog.error("[MXSpaceGraphData] model fromJSON aborted: missing orphanedDirectRoomIdsKey") return nil } diff --git a/MatrixSDK/Threads/MXThreadingService.swift b/MatrixSDK/Threads/MXThreadingService.swift index ff1d3b4c2b..f659614797 100644 --- a/MatrixSDK/Threads/MXThreadingService.swift +++ b/MatrixSDK/Threads/MXThreadingService.swift @@ -338,7 +338,7 @@ public class MXThreadingService: NSObject { case .success(let rootEvent): thread.addEvent(rootEvent, direction: direction) case .failure(let error): - MXLog.error("[MXThreadingService] handleInThreadEvent: root event not found: \(error)") + MXLog.error("[MXThreadingService] handleInThreadEvent: root event not found", context: error) } dispatchGroup.leave() } diff --git a/MatrixSDK/Utils/Categories/FileManager+Backup.swift b/MatrixSDK/Utils/Categories/FileManager+Backup.swift index 9c89f135b9..c006caaf63 100644 --- a/MatrixSDK/Utils/Categories/FileManager+Backup.swift +++ b/MatrixSDK/Utils/Categories/FileManager+Backup.swift @@ -66,7 +66,7 @@ public extension FileManager { do { try excludeItemFromBackup(at: url) } catch { - MXLog.error("[FileManager+Backup]: Cannot exclude url from backup: \(error.localizedDescription)") + MXLog.error("[FileManager+Backup]: Cannot exclude url from backup", context: error) } } } @@ -88,7 +88,7 @@ public extension FileManager { do { urls = try contentsOfDirectory(at: container, includingPropertiesForKeys: nil, options: []) } catch { - MXLog.error("[FileManager+Backup]: Cannot get contents of container: \(error.localizedDescription)") + MXLog.error("[FileManager+Backup]: Cannot get contents of container", context: error) return } @@ -96,7 +96,7 @@ public extension FileManager { do { try excludeItemFromBackup(at: url) } catch { - MXLog.error("[FileManager+Backup]: Cannot exclude url from backup: \(error.localizedDescription)") + MXLog.error("[FileManager+Backup]: Cannot exclude url from backup", context: error) } } } diff --git a/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift b/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift new file mode 100644 index 0000000000..b3a82cb2bb --- /dev/null +++ b/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift @@ -0,0 +1,56 @@ +// +// MXAnalyticsDestination.swift +// MatrixSDK +// +// Created by Element on 22/08/2022. +// + +import Foundation +import SwiftyBeaver + +/// SwiftyBeaver log destination that sends errors to analytics tracker +class MXAnalyticsDestination: BaseDestination { + override var asynchronously: Bool { + get { + return false + } + set { + assertionFailure("Cannot be used asynchronously to preserve strack trace") + } + } + + override var minLevel: SwiftyBeaver.Level { + get { + return .error + } + set { + assertionFailure("Analytics should not track anything less severe than errors") + } + } + + override func send(_ level: SwiftyBeaver.Level, msg: String, thread: String, file: String, function: String, line: Int, context: Any? = nil) -> String? { + let message = super.send(level, msg: msg, thread: thread, file: file, function: function, line: line, context: context) + #if !DEBUG + MXSDKOptions.sharedInstance().analyticsDelegate?.trackNonFatalIssue(msg, details: formattedDetails(from: context)) + #endif + return message + } + + private func formattedDetails(from context: Any?) -> [String: Any]? { + guard let context = context else { + return nil + } + + if let dictionary = context as? [String: Any] { + return dictionary + } else if let error = context as? Error { + return [ + "error": error.localizedDescription + ] + } else { + return [ + "context": String(describing: context) + ] + } + } +} diff --git a/MatrixSDK/Utils/MXLog.h b/MatrixSDK/Utils/Logs/MXLog.h similarity index 63% rename from MatrixSDK/Utils/MXLog.h rename to MatrixSDK/Utils/Logs/MXLog.h index 0eef62b00b..cfb92f6622 100644 --- a/MatrixSDK/Utils/MXLog.h +++ b/MatrixSDK/Utils/Logs/MXLog.h @@ -32,18 +32,18 @@ [MXLogObjcWrapper logWarning:[NSString stringWithFormat: message, ##__VA_ARGS__] file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__]; \ } -#define MXLogError(message, ...) { \ - [MXLogObjcWrapper logError:[NSString stringWithFormat: message, ##__VA_ARGS__] details:nil file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__]; \ +#define MXLogError(message) { \ + [MXLogObjcWrapper logError:message file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__ context:nil]; \ } -#define MXLogErrorWithDetails(message, dictionary) { \ - [MXLogObjcWrapper logError:message details:dictionary file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__]; \ +#define MXLogErrorDetails(message, details) { \ + [MXLogObjcWrapper logError:message file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__ context:details]; \ } -#define MXLogFailure(message, ...) { \ - [MXLogObjcWrapper logFailure:[NSString stringWithFormat: message, ##__VA_ARGS__] details:nil file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__]; \ +#define MXLogFailure(message) { \ + [MXLogObjcWrapper logFailure:message file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__ context:nil]; \ } -#define MXLogFailureWithDetails(message, dictionary) { \ - [MXLogObjcWrapper logFailure:message details:dictionary file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__]; \ +#define MXLogFailureDetails(message, details) { \ + [MXLogObjcWrapper logFailure:message file:@__FILE__ function:[NSString stringWithFormat:@"%s", __FUNCTION__] line:__LINE__ context:details]; \ } diff --git a/MatrixSDK/Utils/MXLog.swift b/MatrixSDK/Utils/Logs/MXLog.swift similarity index 68% rename from MatrixSDK/Utils/MXLog.swift rename to MatrixSDK/Utils/Logs/MXLog.swift index 3a7755bfb4..50d4cceda1 100644 --- a/MatrixSDK/Utils/MXLog.swift +++ b/MatrixSDK/Utils/Logs/MXLog.swift @@ -108,39 +108,65 @@ private var logger: SwiftyBeaver.Type = { logger.warning(message, file, function, line: line) } - public static func error(_ message: @autoclosure () -> Any, - details: @autoclosure () -> [String: Any]? = nil, - _ file: String = #file, _ function: String = #function, line: Int = #line, context: Any? = nil) { - logger.error(formattedMessage(message(), details: details()), file, function, line: line, context: context) - - #if !DEBUG - if let details = details() { - // Tracking errors via analytics as an experiment (provided user consent), but only if details explicitly specified - MXSDKOptions.sharedInstance().analyticsDelegate?.trackNonFatalIssue("\(message())", details: details) - } - #endif + /// Log error with additional details + /// + /// - Parameters: + /// - message: Description of the error without any variables (this is to improve error aggregations by type) + /// - context: Additional context-dependent details about the issue + public static func error( + _ message: StaticString, + _ file: String = #file, + _ function: String = #function, + line: Int = #line, + context: Any? = nil + ) { + logger.error(message, file, function, line: line, context: context) } @available(swift, obsoleted: 5.4) - @objc public static func logError(_ message: String, details: [String: Any]? = nil, file: String, function: String, line: Int) { - error(message, details: details, context: nil) - } - - public static func failure(_ message: @autoclosure () -> Any, - details: @autoclosure () -> [String: Any]? = nil, - _ file: String = #file, _ function: String = #function, line: Int = #line, context: Any? = nil) { - logger.error(formattedMessage(message(), details: details()), file, function, line: line, context: context) - + @objc public static func logError( + _ message: String, + file: String, + function: String, + line: Int, + context: Any? = nil + ) { + logger.error(message, file, function, line: line, context: context) + } + + /// Log failure with additional details + /// + /// A failure is any type of programming error which should never occur in production. In `DEBUG` configuration + /// any failure will raise `assertionFailure` + /// + /// - Parameters: + /// - message: Description of the error without any variables (this is to improve error aggregations by type) + /// - context: Additional context-dependent details about the issue + public static func failure( + _ message: StaticString, + _ file: String = #file, + _ function: String = #function, + line: Int = #line, + context: Any? = nil + ) { + logger.error(message, file, function, line: line, context: context) #if DEBUG - assertionFailure("\(message())") - #else - MXSDKOptions.sharedInstance().analyticsDelegate?.trackNonFatalIssue("\(message())", details: details()) + assertionFailure("\(message)") #endif } @available(swift, obsoleted: 5.4) - @objc public static func logFailure(_ message: String, details: [String: Any]? = nil, file: String, function: String, line: Int) { - failure(message, details: details, file, function, line: line, context: nil) + @objc public static func logFailure( + _ message: String, + file: String, + function: String, + line: Int, + context: Any? = nil + ) { + logger.error(message, file, function, line: line, context: context) + #if DEBUG + assertionFailure("\(message)") + #endif } // MARK: - Private @@ -159,10 +185,12 @@ private var logger: SwiftyBeaver.Type = { return } + logger.removeAllDestinations() + let consoleDestination = ConsoleDestination() consoleDestination.useNSLog = true consoleDestination.asynchronously = false - consoleDestination.format = "$C $M" + consoleDestination.format = "$C $M $X" // Format is `Color Message Context`, see https://docs.swiftybeaver.com/article/20-custom-format consoleDestination.levelColor.verbose = "" consoleDestination.levelColor.debug = "" consoleDestination.levelColor.info = "" @@ -183,52 +211,39 @@ private var logger: SwiftyBeaver.Type = { case .none: break } - - logger.removeAllDestinations() logger.addDestination(consoleDestination) - } - - fileprivate static func formattedMessage(_ message: Any, details: [String: Any]? = nil) -> String { - guard let details = details else { - return "\(message)" - } - return "\(message) - \(details)" + + let analytics = MXAnalyticsDestination() + logger.addDestination(analytics) } } /// Convenience wrapper around `MXLog` which formats all logs as "[Name] function: " +/// +/// Note: Ideally the `format` of `ConsoleDestination` is set to track filename and function automatically +/// (e.g. as `consoleDestination.format = "[$N] $F $C $M $X")`, but this would require the removal of all +/// manually added filenames in logs. struct MXNamedLog { let name: String - func debug(_ message: String, function: String = #function) { - MXLog.debug(formattedMessage(message, function: function)) + func debug(_ message: String, file: String = #file, function: String = #function, line: Int = #line) { + logger.debug(formattedMessage(message, function: function), file, function, line: line) } /// Logging errors requires a static message, all other details must be sent as additional parameters - func error(_ message: StaticString, error: Error? = nil, details: [String: Any]? = nil, function: String = #function) { - MXLog.error( - formattedMessage("\(message)", function: function), - details: formattedDetails(error, otherDetails: details) - ) + func error(_ message: StaticString, context: Any? = nil, file: String = #file, function: String = #function, line: Int = #line) { + logger.error(formattedMessage(message, function: function), file, function, line: line, context: context) } /// Logging failures requires a static message, all other details must be sent as additional parameters - func failure(_ message: StaticString, error: Error? = nil, details: [String: Any]? = nil, function: String = #function) { - MXLog.failure( - formattedMessage("\(message)", function: function), - details: formattedDetails(error, otherDetails: details) - ) + func failure(_ message: StaticString, context: Any? = nil, file: String = #file, function: String = #function, line: Int = #line) { + logger.error(formattedMessage(message, function: function), file, function, line: line, context: context) + #if DEBUG + assertionFailure("\(message)") + #endif } - private func formattedMessage(_ message: String, function: String) -> String { + private func formattedMessage(_ message: Any, function: String) -> String { return "[\(name)] \(function): \(message)" } - - private func formattedDetails(_ error: Error?, otherDetails: [String: Any]?) -> [String: Any]? { - var details = otherDetails ?? [:] - if let error = error { - details["error"] = error - } - return details.isEmpty ? nil : details - } } diff --git a/MatrixSDK/Utils/MXLogObjcWrapper.h b/MatrixSDK/Utils/Logs/MXLogObjcWrapper.h similarity index 79% rename from MatrixSDK/Utils/MXLogObjcWrapper.h rename to MatrixSDK/Utils/Logs/MXLogObjcWrapper.h index 11cbbc7e29..60dd29d114 100644 --- a/MatrixSDK/Utils/MXLogObjcWrapper.h +++ b/MatrixSDK/Utils/Logs/MXLogObjcWrapper.h @@ -31,9 +31,9 @@ NS_ASSUME_NONNULL_BEGIN + (void)logWarning:(NSString *)message file:(NSString *)file function:(NSString *)function line:(NSUInteger)line; -+ (void)logError:(NSString *)message details:(nullable NSDictionary *)details file:(NSString *)file function:(NSString *)function line:(NSUInteger)line; ++ (void)logError:(NSString *)message file:(NSString *)file function:(NSString *)function line:(NSUInteger)line context:(nullable id)context; -+ (void)logFailure:(NSString *)message details:(nullable NSDictionary *)details file:(NSString *)file function:(NSString *)function line:(NSUInteger)line; ++ (void)logFailure:(NSString *)message file:(NSString *)file function:(NSString *)function line:(NSUInteger)line context:(nullable id)context; @end diff --git a/MatrixSDK/Utils/MXLogObjcWrapper.m b/MatrixSDK/Utils/Logs/MXLogObjcWrapper.m similarity index 74% rename from MatrixSDK/Utils/MXLogObjcWrapper.m rename to MatrixSDK/Utils/Logs/MXLogObjcWrapper.m index e6d4ca4197..204fc6d3c1 100644 --- a/MatrixSDK/Utils/MXLogObjcWrapper.m +++ b/MatrixSDK/Utils/Logs/MXLogObjcWrapper.m @@ -39,14 +39,14 @@ + (void)logWarning:(NSString *)message file:(NSString *)file function:(NSString [MXLog logWarning:message file:file function:function line:line]; } -+ (void)logError:(NSString *)message details:(nullable NSDictionary *)details file:(NSString *)file function:(NSString *)function line:(NSUInteger)line ++ (void)logError:(NSString *)message file:(NSString *)file function:(NSString *)function line:(NSUInteger)line context:(id)context { - [MXLog logError:message details:details file:file function:function line:line]; + [MXLog logError:message file:file function:function line:line context:context]; } -+ (void)logFailure:(NSString *)message details:(nullable NSDictionary *)details file:(NSString *)file function:(NSString *)function line:(NSUInteger)line ++ (void)logFailure:(NSString *)message file:(NSString *)file function:(NSString *)function line:(NSUInteger)line context:(id)context { - [MXLog logFailure:message details:details file:file function:function line:line]; + [MXLog logFailure:message file:file function:function line:line context:context]; } @end diff --git a/MatrixSDK/Utils/MXLogger.h b/MatrixSDK/Utils/Logs/MXLogger.h similarity index 100% rename from MatrixSDK/Utils/MXLogger.h rename to MatrixSDK/Utils/Logs/MXLogger.h diff --git a/MatrixSDK/Utils/MXLogger.m b/MatrixSDK/Utils/Logs/MXLogger.m similarity index 99% rename from MatrixSDK/Utils/MXLogger.m rename to MatrixSDK/Utils/Logs/MXLogger.m index ae17feb2d4..8659a5179f 100644 --- a/MatrixSDK/Utils/MXLogger.m +++ b/MatrixSDK/Utils/Logs/MXLogger.m @@ -222,7 +222,9 @@ static void handleUncaughtException(NSException *exception) encoding:NSStringEncodingConversionAllowLossy error:nil]; - MXLogError(@"[MXLogger] handleUncaughtException:\n%@", description); + MXLogErrorDetails(@"[MXLogger] handleUncaughtException", @{ + @"description": description ?: @"unknown" + }); } // Signals emitted by the app are handled here diff --git a/MatrixSDK/Utils/MXServerNotices.m b/MatrixSDK/Utils/MXServerNotices.m index 60e7adfc57..29d82d3df3 100644 --- a/MatrixSDK/Utils/MXServerNotices.m +++ b/MatrixSDK/Utils/MXServerNotices.m @@ -181,7 +181,11 @@ - (void)serverNoticePinnedEvents:(nonnull void (^)(NSArray *pinnedEve } failure:^(NSError *error) { - MXLogError(@"[MXServerNotices] Failed to get pinned event %@ with error: %@. Continue anyway", pinnedEventId, error); + NSDictionary *details = @{ + @"event_id": pinnedEventId ?: @"unknown", + @"error": error ?: @"unknown" + }; + MXLogErrorDetails(@"[MXServerNotices] Failed to get pinned event. Continue anyway", details); dispatch_group_leave(group); }]; } diff --git a/MatrixSDK/VoIP/MXCall.m b/MatrixSDK/VoIP/MXCall.m index f1d946a675..86268d7865 100644 --- a/MatrixSDK/VoIP/MXCall.m +++ b/MatrixSDK/VoIP/MXCall.m @@ -152,7 +152,9 @@ - (instancetype)initWithRoomId:(NSString *)roomId callSignalingRoomId:(NSString callStackCall = [callManager.callStack createCall]; if (nil == callStackCall) { - MXLogError(@"[MXCall][%@] Error: Cannot create call. [MXCallStack createCall] returned nil.", _callId); + MXLogErrorDetails(@"[MXCall] Error: Cannot create call. [MXCallStack createCall] returned nil.", @{ + @"call_id": _callId ?: @"unknown" + }); [callManager.mxSession releasePreventPause]; return nil; } @@ -326,20 +328,22 @@ - (void)callWithVideo:(BOOL)video } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] callWithVideo: ERROR: Cannot send m.call.invite event.", self.callId); + MXLogErrorDetails(@"[MXCall] callWithVideo: ERROR: Cannot send m.call.invite event.", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] callWithVideo: ERROR: Cannot create offer. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] callWithVideo: ERROR: Cannot create offer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] callWithVideo: ERROR: Cannot start capturing media. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] callWithVideo: ERROR: Cannot start capturing media", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonUserMediaFailed]; }]; }]; @@ -409,14 +413,16 @@ - (void)answer } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] answer: ERROR: Cannot send m.call.answer event.", self.callId); + MXLogErrorDetails(@"[MXCall] answer: ERROR: Cannot send m.call.answer event.", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] answer: ERROR: Cannot create answer. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] answer: ERROR: Cannot create answer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; }; @@ -433,7 +439,7 @@ - (void)answer [self->callManager.mxSession.crypto ensureEncryptionInRoom:self.callSignalingRoom.roomId success:answer failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] answer: ERROR: [MXCrypto ensureEncryptionInRoom] failed. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] answer: ERROR: [MXCrypto ensureEncryptionInRoom] failed", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } @@ -508,7 +514,9 @@ - (void)hangupWithReason:(MXCallHangupReason)reason } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] hangup: ERROR: Cannot send m.call.reject event.", self.callId); + MXLogErrorDetails(@"[MXCall] hangup: ERROR: Cannot send m.call.reject event.", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } @@ -553,7 +561,9 @@ - (void)hangupWithReason:(MXCallHangupReason)reason } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] hangupWithReason: ERROR: Cannot send m.call.hangup event.", self.callId); + MXLogErrorDetails(@"[MXCall] hangupWithReason: ERROR: Cannot send m.call.hangup event.", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } @@ -645,14 +655,16 @@ - (void)hold:(BOOL)hold } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] hold: ERROR: Cannot send m.call.negotiate event.", self.callId); + MXLogErrorDetails(@"[MXCall] hold: ERROR: Cannot send m.call.negotiate event.", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } failure:^(NSError * _Nonnull error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] hold: ERROR: Cannot create offer. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] hold: ERROR: Cannot create offer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; }]; @@ -733,7 +745,9 @@ - (void)transferToRoom:(NSString * _Nullable)targetRoomId failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] transferToRoom: ERROR: Cannot send m.call.replaces event.", self.callId); + MXLogErrorDetails(@"[MXCall] transferToRoom: ERROR: Cannot send m.call.replaces event", @{ + @"call_id": self.callId ?: @"unknown" + }); if (failure) { failure(error); @@ -1029,7 +1043,9 @@ - (void)sendLocalIceCandidates [_callSignalingRoom sendEventOfType:kMXEventTypeStringCallCandidates content:content threadId:nil localEcho:nil success:nil failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] onICECandidate: Warning: Cannot send m.call.candidates event.", self.callId); + MXLogErrorDetails(@"[MXCall] onICECandidate: Warning: Cannot send m.call.candidates event", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; @@ -1049,7 +1065,7 @@ - (void)callStackCallDidRemotelyHold:(id)callStackCall - (void)callStackCall:(id)callStackCall onError:(NSError *)error { - MXLogError(@"[MXCall][%@] callStackCall didEncounterError: %@", _callId, error); + MXLogErrorDetails(@"[MXCall] callStackCall didEncounterError", [self detailsForError:error]); if (self.isEstablished) { @@ -1152,7 +1168,7 @@ - (void)handleCallInvite:(MXEvent *)event failure:^(NSError * _Nonnull error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallInvite: ERROR: Couldn't handle offer. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] handleCallInvite: ERROR: Couldn't handle offer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; @@ -1160,7 +1176,7 @@ - (void)handleCallInvite:(MXEvent *)event } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallInvite: startCapturingMediaWithVideo : ERROR: Couldn't start capturing. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] handleCallInvite: startCapturingMediaWithVideo : ERROR: Couldn't start capturing", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonUserMediaFailed]; }]; @@ -1216,7 +1232,7 @@ - (void)handleCallAnswer:(MXEvent *)event failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallAnswer: ERROR: Cannot send handle answer. Error: %@\nEvent: %@", self.callId, error, event); + MXLogErrorDetails(@"[MXCall] handleCallAnswer: ERROR: Cannot send handle answer", [self detailsForError:error]); self.selectedAnswer = nil; [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; @@ -1244,7 +1260,7 @@ - (void)handleCallAnswer:(MXEvent *)event } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallAnswer: ERROR: Cannot send m.call.select_answer event. Error: %@\n", self.callId, error); + MXLogErrorDetails(@"[MXCall] handleCallAnswer: ERROR: Cannot send m.call.select_answer event", [self detailsForError:error]); self.selectedAnswer = nil; [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; @@ -1369,7 +1385,7 @@ - (void)handleCallReject:(MXEvent *)event } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallReject: ERROR: Cannot send m.call.select_answer event. Error: %@\n", self.callId, error); + MXLogErrorDetails(@"[MXCall] handleCallReject: ERROR: Cannot send m.call.select_answer event", [self detailsForError:error]); self.selectedAnswer = nil; [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; @@ -1433,20 +1449,22 @@ - (void)handleCallNegotiate:(MXEvent *)event [self.callSignalingRoom sendEventOfType:kMXEventTypeStringCallNegotiate content:content threadId:nil localEcho:nil success:nil failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallNegotiate: negotiate answer: ERROR: Cannot send m.call.negotiate event.", self.callId); + MXLogErrorDetails(@"[MXCall] handleCallNegotiate: negotiate answer: ERROR: Cannot send m.call.negotiate event.", @{ + @"call_id": self.callId ?: @"unknown" + }); [self didEncounterError:error reason:MXCallHangupReasonUnknownError]; }]; } failure:^(NSError * _Nonnull error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallNegotiate: negotiate answer: ERROR: Cannot create negotiate answer. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] handleCallNegotiate: negotiate answer: ERROR: Cannot create negotiate answer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; } failure:^(NSError * _Nonnull error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallNegotiate: ERROR: Couldn't handle negotiate offer. Error: %@", self.callId, error); + MXLogErrorDetails(@"[MXCall] handleCallNegotiate: ERROR: Couldn't handle negotiate offer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; } @@ -1458,7 +1476,7 @@ - (void)handleCallNegotiate:(MXEvent *)event failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); - MXLogError(@"[MXCall][%@] handleCallNegotiate: ERROR: Cannot send handle negotiate answer. Error: %@\nEvent: %@", self.callId, error, event); + MXLogErrorDetails(@"[MXCall] handleCallNegotiate: ERROR: Cannot send handle negotiate answer", [self detailsForError:error]); [self didEncounterError:error reason:MXCallHangupReasonIceFailed]; }]; } @@ -1741,4 +1759,12 @@ - (void)onCallDeclinedElsewhere [callManager removeCall:self]; } +-(NSDictionary *)detailsForError:(NSError *)error +{ + return @{ + @"call_id": self.callId ?: @"unknown", + @"error": error ?: @"unknown" + }; +} + @end diff --git a/MatrixSDK/VoIP/MXiOSAudioOutputRouter.swift b/MatrixSDK/VoIP/MXiOSAudioOutputRouter.swift index fff3218660..4a7785f653 100644 --- a/MatrixSDK/VoIP/MXiOSAudioOutputRouter.swift +++ b/MatrixSDK/VoIP/MXiOSAudioOutputRouter.swift @@ -189,7 +189,7 @@ public class MXiOSAudioOutputRouter: NSObject { } currentRoute = route } catch { - MXLog.error("[MXiOSAudioOutputRouter] updateRoute: routing failed: \(error)") + MXLog.error("[MXiOSAudioOutputRouter] updateRoute: routing failed", context: error) } } diff --git a/MatrixSDKTests/Utils/MXSessionTracker.swift b/MatrixSDKTests/Utils/MXSessionTracker.swift index 8ba3c9e282..8773370c06 100644 --- a/MatrixSDKTests/Utils/MXSessionTracker.swift +++ b/MatrixSDKTests/Utils/MXSessionTracker.swift @@ -50,9 +50,12 @@ class MXSessionTracker { func printOpenMXSessions() { for (trackId, trackedMXSession) in trackedMXSessions { - MXLog.error("MXSession(\(trackId)) for user \(trackedMXSession.userDeviceId) is not closed. It was created from:") + MXLog.error("MXSession for user is not closed. It was created from:", context: [ + "track_id": trackId, + "user_id": trackedMXSession.userDeviceId + ]) trackedMXSession.callStack.forEach { call in - MXLog.error(" - \(call)") + MXLog.error(" -", context: call) } } } diff --git a/changelog.d/pr-1558.misc b/changelog.d/pr-1558.misc new file mode 100644 index 0000000000..abc1f9031e --- /dev/null +++ b/changelog.d/pr-1558.misc @@ -0,0 +1 @@ +Analytics: Log all errors to analytics