diff --git a/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+zmessaging.m b/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+zmessaging.m index 055fb4964fe..d861f3aa044 100644 --- a/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+zmessaging.m +++ b/wire-ios-data-model/Source/ManagedObjectContext/NSManagedObjectContext+zmessaging.m @@ -25,6 +25,7 @@ #import "ZMManagedObject.h" #import "ZMUser+Internal.h" #import "ZMConversation+Internal.h" +#import "ZMSLogging.h" #import #import diff --git a/wire-ios-data-model/Source/Model/Conversation/ZMConversation.m b/wire-ios-data-model/Source/Model/Conversation/ZMConversation.m index 6f4d40047f6..99f3839b7e6 100644 --- a/wire-ios-data-model/Source/Model/Conversation/ZMConversation.m +++ b/wire-ios-data-model/Source/Model/Conversation/ZMConversation.m @@ -38,6 +38,7 @@ #import "ZMConversationListDirectory.h" #import #import "NSPredicate+ZMSearch.h" +#import "ZMSLogging.h" static NSString* ZMLogTag ZM_UNUSED = @"Conversations"; @@ -583,6 +584,7 @@ - (void)markAsUnread ZMMessage *lastMessageCanBeMarkedUnread = [self lastMessageCanBeMarkedUnread]; if (lastMessageCanBeMarkedUnread == nil) { +TODO: get rid of everything around ZM(S)Log, in production code log to WireLogger, in tests use printing to console, make sure that tests still fail (see hook) ZMLogError(@"Cannot mark as read: no message to mark in %@", self); return; } diff --git a/wire-ios-data-model/Source/Model/Message/ZMMessage.m b/wire-ios-data-model/Source/Model/Message/ZMMessage.m index 76eb7be583b..78302b5cc15 100644 --- a/wire-ios-data-model/Source/Model/Message/ZMMessage.m +++ b/wire-ios-data-model/Source/Model/Message/ZMMessage.m @@ -29,6 +29,7 @@ #import "ZMConversation+UnreadCount.h" #import "ZMUpdateEvent+WireDataModel.h" +#import "ZMSLogging.h" #import #import diff --git a/wire-ios-data-model/Source/Model/Message/ZMOTRMessage.m b/wire-ios-data-model/Source/Model/Message/ZMOTRMessage.m index beecfa393a1..e2d6488239e 100644 --- a/wire-ios-data-model/Source/Model/Message/ZMOTRMessage.m +++ b/wire-ios-data-model/Source/Model/Message/ZMOTRMessage.m @@ -19,7 +19,7 @@ #import "ZMOTRMessage.h" #import "ZMConversation+Internal.h" #import - +#import "ZMSLogging.h" @import WireTransport; diff --git a/wire-ios-data-model/Source/ZMSLogging.h b/wire-ios-data-model/Source/ZMSLogging.h new file mode 100644 index 00000000000..f73e276c2a8 --- /dev/null +++ b/wire-ios-data-model/Source/ZMSLogging.h @@ -0,0 +1,37 @@ +// +// Wire +// Copyright (C) 2025 Wire Swiss GmbH +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/. +// + +#define ZMLogError(format, ...) ZMLogWithLevel(ZMLogLevelError, format, ##__VA_ARGS__) +#define ZMLogWarn(format, ...) ZMLogWithLevel(ZMLogLevelWarn, format, ##__VA_ARGS__) +#define ZMLogDebug(format, ...) ZMLogWithLevelAndTag(ZMLogLevelDebug, ZMLogTag, format, ##__VA_ARGS__) + +#define ZMLogWithLevelAndTag(level, tag_, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:tag_ file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) + +#define ZMLogWithLevel(level, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:0 file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) diff --git a/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj b/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj index 43e34c823b0..fe24f498ed1 100644 --- a/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj +++ b/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj @@ -254,6 +254,7 @@ 5950B0352E2EA1070051B07A /* GenericMessageProtocol in Frameworks */ = {isa = PBXBuildFile; productRef = 5950B0342E2EA1070051B07A /* GenericMessageProtocol */; }; 5950B0372E2EA1220051B07A /* GenericMessageProtocol in Frameworks */ = {isa = PBXBuildFile; productRef = 5950B0362E2EA1220051B07A /* GenericMessageProtocol */; }; 59537CDB2CFF8F2B00920B59 /* WireLogging in Frameworks */ = {isa = PBXBuildFile; productRef = 59537CDA2CFF8F2B00920B59 /* WireLogging */; }; + 596224E22EB12B4600683C3F /* ZMSLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 596224E12EB12B4600683C3F /* ZMSLogging.h */; }; 5966D8302BD6AA4100305BBC /* UserPropertyNormalization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5966D82F2BD6AA4100305BBC /* UserPropertyNormalization.swift */; }; 5966D8322BD6AA8200305BBC /* UserPropertyNormalizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5966D8312BD6AA8200305BBC /* UserPropertyNormalizer.swift */; }; 5966D8342BD6ADCA00305BBC /* UserPropertyNormalizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5966D8332BD6ADCA00305BBC /* UserPropertyNormalizerTests.swift */; }; @@ -1019,6 +1020,7 @@ 591F8A052B8CB81400D562A6 /* IsSelfUserE2EICertifiedUseCaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IsSelfUserE2EICertifiedUseCaseTests.swift; sourceTree = ""; }; 5930D9C22D43BC33009E3514 /* zmessaging2.121.0.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = zmessaging2.121.0.xcdatamodel; sourceTree = ""; }; 5947923C2EA7A576006BEC0A /* store2-131-0.wiredatabase */ = {isa = PBXFileReference; lastKnownFileType = file; path = "store2-131-0.wiredatabase"; sourceTree = ""; }; + 596224E12EB12B4600683C3F /* ZMSLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZMSLogging.h; sourceTree = ""; }; 5966D82F2BD6AA4100305BBC /* UserPropertyNormalization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPropertyNormalization.swift; sourceTree = ""; }; 5966D8312BD6AA8200305BBC /* UserPropertyNormalizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserPropertyNormalizer.swift; sourceTree = ""; }; 5966D8332BD6ADCA00305BBC /* UserPropertyNormalizerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPropertyNormalizerTests.swift; sourceTree = ""; }; @@ -2999,6 +3001,7 @@ F9A7061B1CAEE01D00C2F5FE /* Notifications */, F9A706421CAEE01D00C2F5FE /* Utilis */, F9C9A60C1CAD76A50039E10C /* WireDataModel.h */, + 596224E12EB12B4600683C3F /* ZMSLogging.h */, F9C9A7371CAE6D890039E10C /* ConversationList */, 599EA3D12C246897009319D4 /* ConversationSearch */, F9C9A6A01CAD7C7F0039E10C /* Public */, @@ -3219,6 +3222,7 @@ files = ( F9A706C81CAEE01D00C2F5FE /* ZMUpdateEvent+WireDataModel.h in Headers */, F9331C871CB419B500139ECC /* NSFetchRequest+ZMRelationshipKeyPaths.h in Headers */, + 596224E22EB12B4600683C3F /* ZMSLogging.h in Headers */, F9A706561CAEE01D00C2F5FE /* NSNotification+ManagedObjectContextSave.h in Headers */, 59EC73F72C20B03100E5C036 /* NSManagedObjectContext+executeFetchRequestOrAssert.h in Headers */, F9A706801CAEE01D00C2F5FE /* ZMMessage+Internal.h in Headers */, diff --git a/wire-ios-mocktransport/Source/MockTransportSession.m b/wire-ios-mocktransport/Source/MockTransportSession.m index 04edce003b8..718ba27f5bd 100644 --- a/wire-ios-mocktransport/Source/MockTransportSession.m +++ b/wire-ios-mocktransport/Source/MockTransportSession.m @@ -30,6 +30,7 @@ #import "MockReachability.h" #import "WireMockTransport/WireMockTransport-Swift.h" #import "NSManagedObjectContext+executeFetchRequestOrAssert.h" +#import "ZMSLogging.h" NSString * const ZMPushChannelStateChangeNotificationName = @"ZMPushChannelStateChangeNotification"; NSString * const ZMPushChannelIsOpenKey = @"pushChannelIsOpen"; diff --git a/wire-ios-mocktransport/Source/ZMSLogging.h b/wire-ios-mocktransport/Source/ZMSLogging.h new file mode 100644 index 00000000000..2d6a436f987 --- /dev/null +++ b/wire-ios-mocktransport/Source/ZMSLogging.h @@ -0,0 +1,36 @@ +// +// Wire +// Copyright (C) 2025 Wire Swiss GmbH +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/. +// + +#define ZMLogError(format, ...) ZMLogWithLevel(ZMLogLevelError, format, ##__VA_ARGS__) +#define ZMLogDebug(format, ...) ZMLogWithLevelAndTag(ZMLogLevelDebug, ZMLogTag, format, ##__VA_ARGS__) + +#define ZMLogWithLevelAndTag(level, tag_, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:tag_ file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) + +#define ZMLogWithLevel(level, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:0 file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) diff --git a/wire-ios-mocktransport/Tests/Source/MockTransportSessionTests.m b/wire-ios-mocktransport/Tests/Source/MockTransportSessionTests.m index bc126d46e6a..498b0abf371 100644 --- a/wire-ios-mocktransport/Tests/Source/MockTransportSessionTests.m +++ b/wire-ios-mocktransport/Tests/Source/MockTransportSessionTests.m @@ -26,6 +26,7 @@ #import "MockTransportSessionTests.h" #import #import +#import "ZMSLogging.h" @interface TestPushChannelEvent() diff --git a/wire-ios-request-strategy/Sources/Object Syncs/Upstream/ZMUpstreamInsertedObjectSync.m b/wire-ios-request-strategy/Sources/Object Syncs/Upstream/ZMUpstreamInsertedObjectSync.m index b41b101a226..96e8edb0f3f 100644 --- a/wire-ios-request-strategy/Sources/Object Syncs/Upstream/ZMUpstreamInsertedObjectSync.m +++ b/wire-ios-request-strategy/Sources/Object Syncs/Upstream/ZMUpstreamInsertedObjectSync.m @@ -26,6 +26,7 @@ #import "ZMLocallyModifiedObjectSet.h" #import "ZMUpstreamTranscoder.h" #import "ZMUpstreamRequest.h" +#import "ZMSLogging.h" @interface ZMUpstreamInsertedObjectSync () diff --git a/wire-ios-request-strategy/Sources/Request Strategies/Base Strategies/ZMAbstractRequestStrategy.m b/wire-ios-request-strategy/Sources/Request Strategies/Base Strategies/ZMAbstractRequestStrategy.m index 2a0d903dd1c..5749df4cff8 100644 --- a/wire-ios-request-strategy/Sources/Request Strategies/Base Strategies/ZMAbstractRequestStrategy.m +++ b/wire-ios-request-strategy/Sources/Request Strategies/Base Strategies/ZMAbstractRequestStrategy.m @@ -19,6 +19,7 @@ #import #import #import "ZMAbstractRequestStrategy.h" +#import "ZMSLogging.h" static NSString* ZMLogTag ZM_UNUSED = @"Request Configuration"; diff --git a/wire-ios-request-strategy/Sources/ZMSLogging.h b/wire-ios-request-strategy/Sources/ZMSLogging.h new file mode 100644 index 00000000000..d11d99812d3 --- /dev/null +++ b/wire-ios-request-strategy/Sources/ZMSLogging.h @@ -0,0 +1,28 @@ +// +// Wire +// Copyright (C) 2025 Wire Swiss GmbH +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/. +// + +#define ZMLogInfo(format, ...) ZMLogWithLevelAndTag(ZMLogLevelInfo, ZMLogTag, format, ##__VA_ARGS__) +#define ZMLogDebug(format, ...) ZMLogWithLevelAndTag(ZMLogLevelDebug, ZMLogTag, format, ##__VA_ARGS__) + +#define ZMLogWithLevelAndTag(level, tag_, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:tag_ file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) diff --git a/wire-ios-request-strategy/WireRequestStrategy.xcodeproj/project.pbxproj b/wire-ios-request-strategy/WireRequestStrategy.xcodeproj/project.pbxproj index fabffaa524e..8d1b11f7375 100644 --- a/wire-ios-request-strategy/WireRequestStrategy.xcodeproj/project.pbxproj +++ b/wire-ios-request-strategy/WireRequestStrategy.xcodeproj/project.pbxproj @@ -195,6 +195,7 @@ 59271BF02B90D2510019B726 /* MockOTREntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59271BEE2B90D24A0019B726 /* MockOTREntity.swift */; }; 59537D852CFF9D1600920B59 /* WireLogging in Frameworks */ = {isa = PBXBuildFile; productRef = 59537D842CFF9D1600920B59 /* WireLogging */; }; 59537D872CFF9DF600920B59 /* WireLogging in Frameworks */ = {isa = PBXBuildFile; productRef = 59537D862CFF9DF600920B59 /* WireLogging */; }; + 596224E42EB12C0800683C3F /* ZMSLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 596224E32EB12C0800683C3F /* ZMSLogging.h */; }; 597B70C92B03CC76006C2121 /* UpdateConversationProtocolActionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 597B70C82B03CC76006C2121 /* UpdateConversationProtocolActionHandler.swift */; }; 597B70CC2B03CC83006C2121 /* UpdateConversationProtocolActionHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 597B70CA2B03CC7D006C2121 /* UpdateConversationProtocolActionHandlerTests.swift */; }; 598D04302C89C67E00B64D71 /* WireFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 598D042F2C89C67E00B64D71 /* WireFoundation */; }; @@ -700,6 +701,7 @@ 547E664C1F7512FE008CB1FA /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 59271BEC2B90D2140019B726 /* ClientRegistrationDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientRegistrationDelegate.swift; sourceTree = ""; }; 59271BEE2B90D24A0019B726 /* MockOTREntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockOTREntity.swift; sourceTree = ""; }; + 596224E32EB12C0800683C3F /* ZMSLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZMSLogging.h; sourceTree = ""; }; 597B70C82B03CC76006C2121 /* UpdateConversationProtocolActionHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateConversationProtocolActionHandler.swift; sourceTree = ""; }; 597B70CA2B03CC7D006C2121 /* UpdateConversationProtocolActionHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateConversationProtocolActionHandlerTests.swift; sourceTree = ""; }; 598E870C2BF4E08100FC5438 /* WireUtilitiesSupport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WireUtilitiesSupport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1356,6 +1358,7 @@ F1CD5D822024C1A0008C574E /* Request Syncs */, E69A021F2B85095F00126FF6 /* Services */, 06474D4824AF6825002C695D /* Synchronization */, + 596224E32EB12C0800683C3F /* ZMSLogging.h */, 1669016D1D707509000FE4AF /* WireRequestStrategy.h */, ); path = Sources; @@ -2135,6 +2138,7 @@ 166901DF1D7081C7000FE4AF /* ZMRemoteIdentifierObjectSync.h in Headers */, 166901F61D7081C7000FE4AF /* ZMUpstreamTranscoder.h in Headers */, 166901E51D7081C7000FE4AF /* ZMSyncOperationSet.h in Headers */, + 596224E42EB12C0800683C3F /* ZMSLogging.h in Headers */, 166901F31D7081C7000FE4AF /* ZMUpstreamModifiedObjectSync+Testing.h in Headers */, 166901D01D7081C7000FE4AF /* ZMContextChangeTracker.h in Headers */, 166901E31D7081C7000FE4AF /* ZMSingleRequestSync.h in Headers */, diff --git a/wire-ios-sync-engine/Source/Synchronization/Transcoders/ZMMissingUpdateEventsTranscoder.m b/wire-ios-sync-engine/Source/Synchronization/Transcoders/ZMMissingUpdateEventsTranscoder.m index 6da68f0f7dd..88695fa71c5 100644 --- a/wire-ios-sync-engine/Source/Synchronization/Transcoders/ZMMissingUpdateEventsTranscoder.m +++ b/wire-ios-sync-engine/Source/Synchronization/Transcoders/ZMMissingUpdateEventsTranscoder.m @@ -23,7 +23,7 @@ #import "ZMMissingUpdateEventsTranscoder+Internal.h" #import #import "WireSyncEngineLogs.h" - +#import "ZMSLogging.h" static NSString * const LastUpdateEventIDStoreKey = @"LastUpdateEventID"; static NSString * const NotificationsKey = @"notifications"; diff --git a/wire-ios-sync-engine/Source/Synchronization/ZMSyncStrategy+ManagedObjectChanges.m b/wire-ios-sync-engine/Source/Synchronization/ZMSyncStrategy+ManagedObjectChanges.m index f3b156e25b4..4c3f4455133 100644 --- a/wire-ios-sync-engine/Source/Synchronization/ZMSyncStrategy+ManagedObjectChanges.m +++ b/wire-ios-sync-engine/Source/Synchronization/ZMSyncStrategy+ManagedObjectChanges.m @@ -20,6 +20,7 @@ #import "ZMSyncStrategy+ManagedObjectChanges.h" #import "WireSyncEngineLogs.h" #import +#import "ZMSLogging.h" @implementation ZMSyncStrategy (ManagedObjectChanges) diff --git a/wire-ios-sync-engine/Source/UnauthenticatedSession/ZMAuthenticationStatus.m b/wire-ios-sync-engine/Source/UnauthenticatedSession/ZMAuthenticationStatus.m index 5cb2eb9bfb7..58af30506df 100644 --- a/wire-ios-sync-engine/Source/UnauthenticatedSession/ZMAuthenticationStatus.m +++ b/wire-ios-sync-engine/Source/UnauthenticatedSession/ZMAuthenticationStatus.m @@ -27,6 +27,7 @@ #import "ZMUserSessionRegistrationNotification.h" #import #import "ZMAuthenticationStatus_Internal.h" +#import "ZMSLogging.h" static NSString *const TimerInfoOriginalCredentialsKey = @"credentials"; static NSString *const AuthenticationCenterDataChangeNotificationName = @"ZMAuthenticationStatusDataChangeNotificationName"; diff --git a/wire-ios-sync-engine/Source/UserSession/ZMBlacklistDownloader.m b/wire-ios-sync-engine/Source/UserSession/ZMBlacklistDownloader.m index a4796457704..dc63b0967cf 100644 --- a/wire-ios-sync-engine/Source/UserSession/ZMBlacklistDownloader.m +++ b/wire-ios-sync-engine/Source/UserSession/ZMBlacklistDownloader.m @@ -23,6 +23,7 @@ #import "ZMBlacklistDownloader+Testing.h" #import +#import "ZMSLogging.h" static NSString *ZMLogTag ZM_UNUSED = @"Blacklist"; diff --git a/wire-ios-sync-engine/Source/ZMSLogging.h b/wire-ios-sync-engine/Source/ZMSLogging.h new file mode 100644 index 00000000000..b5fc2959818 --- /dev/null +++ b/wire-ios-sync-engine/Source/ZMSLogging.h @@ -0,0 +1,37 @@ +// +// Wire +// Copyright (C) 2025 Wire Swiss GmbH +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/. +// + +#define ZMLogError(format, ...) ZMLogWithLevel(ZMLogLevelError, format, ##__VA_ARGS__) +#define ZMLogInfo(format, ...) ZMLogWithLevelAndTag(ZMLogLevelInfo, ZMLogTag, format, ##__VA_ARGS__) +#define ZMLogDebug(format, ...) ZMLogWithLevelAndTag(ZMLogLevelDebug, ZMLogTag, format, ##__VA_ARGS__) + +#define ZMLogWithLevelAndTag(level, tag_, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:tag_ file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) + +#define ZMLogWithLevel(level, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:0 file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) diff --git a/wire-ios-sync-engine/Tests/Source/MessagingTest.m b/wire-ios-sync-engine/Tests/Source/MessagingTest.m index 37c165cb2fe..06cdb1b0aa9 100644 --- a/wire-ios-sync-engine/Tests/Source/MessagingTest.m +++ b/wire-ios-sync-engine/Tests/Source/MessagingTest.m @@ -38,6 +38,7 @@ #import "ZMLastUpdateEventIDTranscoder.h" #import "ZMLoginTranscoder.h" #import "ZMLoginCodeRequestTranscoder.h" +#import "ZMSLogging.h" #import #import "Tests-Swift.h" diff --git a/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj b/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj index 42b2d3c736a..32e29bf78b8 100644 --- a/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj +++ b/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj @@ -260,6 +260,7 @@ 594C0FCE2D541643003D8183 /* WireDomainPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 594C0FCD2D541643003D8183 /* WireDomainPackage */; }; 594EAA002EA23E73009BC0EB /* WireUtilitiesPackageSupport in Frameworks */ = {isa = PBXBuildFile; productRef = 594EA9FF2EA23E73009BC0EB /* WireUtilitiesPackageSupport */; }; 59537D892CFF9E7700920B59 /* WireLogging in Frameworks */ = {isa = PBXBuildFile; productRef = 59537D882CFF9E7700920B59 /* WireLogging */; }; + 596224E62EB12CAA00683C3F /* ZMSLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 596224E52EB12CAA00683C3F /* ZMSLogging.h */; }; 596A19EA2E9E523100E190AE /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 596A19E92E9E523100E190AE /* ZIPFoundation */; }; 5972B0D92E9EAB78005E6417 /* WireUtilitiesPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 5972B0D82E9EAB78005E6417 /* WireUtilitiesPackage */; }; 597B70C32B03984C006C2121 /* ZMUserSession+DeveloperMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 597B70C22B03984C006C2121 /* ZMUserSession+DeveloperMenu.swift */; }; @@ -845,6 +846,7 @@ 59271BE72B908DAC0019B726 /* SecurityClassificationProviding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityClassificationProviding.swift; sourceTree = ""; }; 59271BE92B908E150019B726 /* SecurityClassification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityClassification.swift; sourceTree = ""; }; 5943E9BB2D11CB3300D39FFF /* CallEndedReason+initWithCallClosedReason.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CallEndedReason+initWithCallClosedReason.swift"; sourceTree = ""; }; + 596224E52EB12CAA00683C3F /* ZMSLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZMSLogging.h; sourceTree = ""; }; 597B70C22B03984C006C2121 /* ZMUserSession+DeveloperMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ZMUserSession+DeveloperMenu.swift"; sourceTree = ""; }; 598E87012BF4DE9600FC5438 /* WireSystemSupport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WireSystemSupport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 598E87042BF4E01300FC5438 /* WireUtilitiesSupport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WireUtilitiesSupport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1660,6 +1662,7 @@ EE88B0522BF62B430013F0BD /* Services */, 59DBECA72D3965570069C64C /* Use cases */, 3E18605B191A4F28000FE027 /* Public */, + 596224E52EB12CAA00683C3F /* ZMSLogging.h */, 3E18605C191A4F3B000FE027 /* WireSyncEngine-iOS.pch */, E9E4D4702C2AD61500364352 /* TeamRole+AnalyticsValue.swift */, E955D3DE2C36CFFF0090BEAB /* ConversationType+ZMConversationType.swift */, @@ -2471,6 +2474,7 @@ 1602B4611F3B04150061C135 /* ZMBlacklistVerificator.h in Headers */, 5430E9251BAA0D9F00395E05 /* WireSyncEngineLogs.h in Headers */, 06DE14CF24B85CA0006CB6B3 /* ZMClientRegistrationStatusDelegate.h in Headers */, + 596224E62EB12CAA00683C3F /* ZMSLogging.h in Headers */, 09531F161AE960E300B8556A /* ZMLoginCodeRequestTranscoder.h in Headers */, EE0CAEB12AAF306000BD2DB7 /* ZMBlacklistDownloader.h in Headers */, 544BA1271A433DE400D3B852 /* NSError+ZMUserSession.h in Headers */, diff --git a/wire-ios-sync-engine/WireSyncEngine.xcodeproj/xcshareddata/xcschemes/WireSyncEngine.xcscheme b/wire-ios-sync-engine/WireSyncEngine.xcodeproj/xcshareddata/xcschemes/WireSyncEngine.xcscheme index af0038aeabf..48e0dfa5e79 100644 --- a/wire-ios-sync-engine/WireSyncEngine.xcodeproj/xcshareddata/xcschemes/WireSyncEngine.xcscheme +++ b/wire-ios-sync-engine/WireSyncEngine.xcodeproj/xcshareddata/xcschemes/WireSyncEngine.xcscheme @@ -135,12 +135,12 @@ diff --git a/wire-ios-system/Source/WireSystem.h b/wire-ios-system/Source/WireSystem.h index a4259850387..b43d26ebf19 100644 --- a/wire-ios-system/Source/WireSystem.h +++ b/wire-ios-system/Source/WireSystem.h @@ -28,4 +28,3 @@ FOUNDATION_EXPORT const unsigned char ZMSystemVersionString[]; #import #import -#import diff --git a/wire-ios-system/Source/ZMSLog.swift b/wire-ios-system/Source/ZMSLog.swift index 2956ebd5e38..fbed79ee7d0 100644 --- a/wire-ios-system/Source/ZMSLog.swift +++ b/wire-ios-system/Source/ZMSLog.swift @@ -118,7 +118,7 @@ public extension ZMSLog { // MARK: - Conditional execution -// These let us run code only if the log level is set correspondingly. That can be usefull when creating the logging is +// These let us run code only if the log level is set correspondingly. That can be useful when creating the logging is // expensive. // // zmLog.ifError { diff --git a/wire-ios-system/WireSystem.xcodeproj/project.pbxproj b/wire-ios-system/WireSystem.xcodeproj/project.pbxproj index 1c67450f2f2..3c251cd173f 100644 --- a/wire-ios-system/WireSystem.xcodeproj/project.pbxproj +++ b/wire-ios-system/WireSystem.xcodeproj/project.pbxproj @@ -65,7 +65,6 @@ WireSystem.h, ZMSAsserts.h, ZMSDefines.h, - ZMSLogging.h, ); target = 3ECC350F1AD436750089FD4B /* WireSystem */; }; @@ -124,7 +123,6 @@ 5953DD242CF0CA900069ABC8 /* Source */, 5939CB872CEBB2BA000F6FAD /* Support */, 5953DE452CF0CD2A0069ABC8 /* Tests */, - E66EC68A2B21D179003052F7 /* Frameworks */, 3ECC34E61AD433520089FD4B /* Products */, ); indentWidth = 4; @@ -143,13 +141,6 @@ name = Products; sourceTree = ""; }; - E66EC68A2B21D179003052F7 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ diff --git a/wire-ios-testing/Source/Public/NSData+WireTesting.h b/wire-ios-testing/Source/Public/NSData+WireTesting.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/wire-ios-testing/Source/Public/NSData+WireTesting.m b/wire-ios-testing/Source/Public/NSData+WireTesting.m deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/wire-ios-testing/WireTesting.xcodeproj/project.pbxproj b/wire-ios-testing/WireTesting.xcodeproj/project.pbxproj index 661c5ff01eb..261bf38bb18 100644 --- a/wire-ios-testing/WireTesting.xcodeproj/project.pbxproj +++ b/wire-ios-testing/WireTesting.xcodeproj/project.pbxproj @@ -37,7 +37,6 @@ publicHeaders = ( "Public/Mock Data Model/ZMMockEntity.h", "Public/Mock Data Model/ZMMockEntity2.h", - "Public/NSData+WireTesting.h", "Public/NSOperationQueue+WireTesting.h", "Public/NSUUID+WireTesting.h", Public/WireTesting.h, diff --git a/wire-ios-transport/Source/Authentication/ZMKeychain.m b/wire-ios-transport/Source/Authentication/ZMKeychain.m index 7436d690723..0937dd5c779 100644 --- a/wire-ios-transport/Source/Authentication/ZMKeychain.m +++ b/wire-ios-transport/Source/Authentication/ZMKeychain.m @@ -21,6 +21,7 @@ @import WireUtilities; #import "ZMKeychain.h" +#import "ZMSLogging.h" static char* const ZMLogTag ZM_UNUSED = "Keychain"; diff --git a/wire-ios-transport/Source/Authentication/ZMPersistentCookieStorage.m b/wire-ios-transport/Source/Authentication/ZMPersistentCookieStorage.m index 6f8a97eded4..70dd99ed0ac 100644 --- a/wire-ios-transport/Source/Authentication/ZMPersistentCookieStorage.m +++ b/wire-ios-transport/Source/Authentication/ZMPersistentCookieStorage.m @@ -25,6 +25,7 @@ #import "ZMPersistentCookieStorage.h" #import #import "ZMKeychain.h" +#import "ZMSLogging.h" static NSString * const CookieName = @"zuid"; static NSString * const LegacyAccountName = @"User"; diff --git a/wire-ios-transport/Source/Background/ZMTemporaryFileListForBackgroundRequests.m b/wire-ios-transport/Source/Background/ZMTemporaryFileListForBackgroundRequests.m index 42dc70e4a03..47dd12ef2f0 100644 --- a/wire-ios-transport/Source/Background/ZMTemporaryFileListForBackgroundRequests.m +++ b/wire-ios-transport/Source/Background/ZMTemporaryFileListForBackgroundRequests.m @@ -19,6 +19,7 @@ @import WireSystem; #import "ZMTemporaryFileListForBackgroundRequests.h" #import "ZMTaskIdentifierMap.h" +#import "ZMSLogging.h" static NSString * const TemporaryDirectoryName = @"com.wire.zmessaging.ZMTemporaryFileListForBackgroundRequests"; diff --git a/wire-ios-system/Source/ZMSLogging.h b/wire-ios-transport/Source/Logging/ZMSLogging.h similarity index 92% rename from wire-ios-system/Source/ZMSLogging.h rename to wire-ios-transport/Source/Logging/ZMSLogging.h index ae914928e32..8c429d16d5c 100644 --- a/wire-ios-system/Source/ZMSLogging.h +++ b/wire-ios-transport/Source/Logging/ZMSLogging.h @@ -16,9 +16,6 @@ // along with this program. If not, see http://www.gnu.org/licenses/. // -#import - -#define ZMLogPublic(format, ...) ZMLogWithLevelAndTag(ZMLogLevelPublic, ZMLogTag, format, ##__VA_ARGS__) #define ZMLogError(format, ...) ZMLogWithLevel(ZMLogLevelError, format, ##__VA_ARGS__) #define ZMLogWarn(format, ...) ZMLogWithLevel(ZMLogLevelWarn, format, ##__VA_ARGS__) #define ZMLogInfo(format, ...) ZMLogWithLevelAndTag(ZMLogLevelInfo, ZMLogTag, format, ##__VA_ARGS__) diff --git a/wire-ios-transport/Source/Requests/ZMExponentialBackoff.m b/wire-ios-transport/Source/Requests/ZMExponentialBackoff.m index b713e3f5ee6..7b89f38eb81 100644 --- a/wire-ios-transport/Source/Requests/ZMExponentialBackoff.m +++ b/wire-ios-transport/Source/Requests/ZMExponentialBackoff.m @@ -17,6 +17,7 @@ // #import "ZMExponentialBackoff.h" +#import "ZMSLogging.h" #import "ZMTLogging.h" @import WireSystem; diff --git a/wire-ios-transport/Source/Requests/ZMTransportResponse.m b/wire-ios-transport/Source/Requests/ZMTransportResponse.m index 149d00c7d47..666834f106a 100644 --- a/wire-ios-transport/Source/Requests/ZMTransportResponse.m +++ b/wire-ios-transport/Source/Requests/ZMTransportResponse.m @@ -27,6 +27,7 @@ #import "ZMTransportCodec.h" #import "ZMTransportSession.h" #import "Collections+ZMTSafeTypes.h" +#import "ZMSLogging.h" #import "ZMTLogging.h" #import diff --git a/wire-ios-transport/Source/TransportSession/ZMTransportRequestScheduler.m b/wire-ios-transport/Source/TransportSession/ZMTransportRequestScheduler.m index 09f35022ab4..4bb47861070 100644 --- a/wire-ios-transport/Source/TransportSession/ZMTransportRequestScheduler.m +++ b/wire-ios-transport/Source/TransportSession/ZMTransportRequestScheduler.m @@ -20,6 +20,7 @@ #import "ZMTransportRequestScheduler.h" #import "ZMExponentialBackoff.h" +#import "ZMSLogging.h" #import "ZMTLogging.h" #import diff --git a/wire-ios-transport/Source/TransportSession/ZMTransportSession.m b/wire-ios-transport/Source/TransportSession/ZMTransportSession.m index 647dc543700..e4cbaacb589 100644 --- a/wire-ios-transport/Source/TransportSession/ZMTransportSession.m +++ b/wire-ios-transport/Source/TransportSession/ZMTransportSession.m @@ -33,6 +33,7 @@ #import "NSError+ZMTransportSession.h" #import "ZMUserAgent.h" #import "ZMURLSession.h" +#import "ZMSLogging.h" #import "ZMTLogging.h" #import "NSData+Multipart.h" #import "ZMTaskIdentifier.h" diff --git a/wire-ios-transport/Source/URLSession/ZMReachability.m b/wire-ios-transport/Source/URLSession/ZMReachability.m index a7cdfc4fa4f..bc84812ef7b 100644 --- a/wire-ios-transport/Source/URLSession/ZMReachability.m +++ b/wire-ios-transport/Source/URLSession/ZMReachability.m @@ -23,6 +23,7 @@ #import "ZMReachability.h" #import #import +#import "ZMSLogging.h" #import "ZMTLogging.h" static NSString* ZMLogTag ZM_UNUSED = ZMT_LOG_TAG_NETWORK; diff --git a/wire-ios-transport/Source/URLSession/ZMURLSession.m b/wire-ios-transport/Source/URLSession/ZMURLSession.m index 70e0a90bca9..d114540c45a 100644 --- a/wire-ios-transport/Source/URLSession/ZMURLSession.m +++ b/wire-ios-transport/Source/URLSession/ZMURLSession.m @@ -24,6 +24,7 @@ #import "ZMTaskIdentifierMap.h" #import "ZMTemporaryFileListForBackgroundRequests.h" #import "ZMTransportRequest+Internal.h" +#import "ZMSLogging.h" #import "ZMTLogging.h" #import "ZMTransportResponse.h" #import diff --git a/wire-ios-utilities/Source/NSData+ZMSCrypto.m b/wire-ios-utilities/Source/NSData+ZMSCrypto.m index 9d6fe6e79d9..5b8e7e1367a 100644 --- a/wire-ios-utilities/Source/NSData+ZMSCrypto.m +++ b/wire-ios-utilities/Source/NSData+ZMSCrypto.m @@ -19,6 +19,7 @@ @import WireSystem; #import "NSData+ZMSCrypto.h" #import +#import "ZMSLogging.h" static NSString* ZMLogTag ZM_UNUSED = @"SymmetricEncryption"; diff --git a/wire-ios-utilities/Source/ZMEncodedNSUUIDWithTimestamp.m b/wire-ios-utilities/Source/ZMEncodedNSUUIDWithTimestamp.m index 8b091279d94..c72ee4c1675 100644 --- a/wire-ios-utilities/Source/ZMEncodedNSUUIDWithTimestamp.m +++ b/wire-ios-utilities/Source/ZMEncodedNSUUIDWithTimestamp.m @@ -22,6 +22,7 @@ #import "ZMEncodedNSUUIDWithTimestamp.h" #import "NSUUID+Data.h" #import +#import "ZMSLogging.h" static const uint8_t RANDOM_DATA_SIZE = 14; static const uint8_t TIME_DATA_SIZE = 2; diff --git a/wire-ios-utilities/Source/ZMSLogging.h b/wire-ios-utilities/Source/ZMSLogging.h new file mode 100644 index 00000000000..51d7c9846d6 --- /dev/null +++ b/wire-ios-utilities/Source/ZMSLogging.h @@ -0,0 +1,37 @@ +// +// Wire +// Copyright (C) 2025 Wire Swiss GmbH +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/. +// + + #define ZMLogError(format, ...) ZMLogWithLevel(ZMLogLevelError, format, ##__VA_ARGS__) + #define ZMLogWarn(format, ...) ZMLogWithLevel(ZMLogLevelWarn, format, ##__VA_ARGS__) + #define ZMLogDebug(format, ...) ZMLogWithLevelAndTag(ZMLogLevelDebug, ZMLogTag, format, ##__VA_ARGS__) + + #define ZMLogWithLevelAndTag(level, tag_, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:tag_ file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0) + + #define ZMLogWithLevel(level, format, ...) \ + do { \ + NSString *message = [[NSString alloc] initWithFormat:format, ##__VA_ARGS__]; \ + [ZMSLog logWithLevel:level message:^NSString * _Nonnull { \ + return message; \ + } tag:0 file:[NSString stringWithUTF8String:__FILE__] line:(NSUInteger)__LINE__]; \ + } while (0)