Skip to content

Commit 2699f74

Browse files
Revert "Structured Logs: Add log APIs to Hub and Client (#6518)" (#6727)
This reverts commit 324157f.
1 parent 324157f commit 2699f74

25 files changed

+938
-1381
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
- Move `enableDataSwizzling` from experimental options to top-level options (#6592). This option remains enabled by default.
6565
- Add `sentry.replay_id` attribute to logs ([#6515](https://github.com/getsentry/sentry-cocoa/pull/6515))
6666
- Structured Logs: Add `SentrySwiftLog` Integration (#6286)
67-
- Structured Logs: Add log APIs to `Hub` and `Client` (#6518)
6867

6968
## 8.57.2
7069

Sentry.xcodeproj/project.pbxproj

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,6 @@
725725
9241AC442EBA39A500E611ED /* SentrySwiftLog.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9241AC132EBA38CB00E611ED /* SentrySwiftLog.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
726726
9241AC4F2EBA3A0C00E611ED /* SentryLogHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9241AC4D2EBA3A0C00E611ED /* SentryLogHandlerTests.swift */; };
727727
925824C22CB5897700C9B20B /* SentrySessionReplayIntegration-Hybrid.h in Headers */ = {isa = PBXBuildFile; fileRef = D80382BE2C09C6FD0090E048 /* SentrySessionReplayIntegration-Hybrid.h */; settings = {ATTRIBUTES = (Private, ); }; };
728-
92622E092EABB71000ABE7FF /* SentryLogSPMTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92622E082EABB71000ABE7FF /* SentryLogSPMTests.swift */; };
729-
92622E142EABBDA900ABE7FF /* SentryLog+SPM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92622E132EABBDA900ABE7FF /* SentryLog+SPM.swift */; };
730728
9264E1EB2E2E385E00B077CF /* SentryLogMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264E1EA2E2E385B00B077CF /* SentryLogMessage.swift */; };
731729
9264E1ED2E2E397C00B077CF /* SentryLogMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264E1EC2E2E397400B077CF /* SentryLogMessageTests.swift */; };
732730
92672BB629C9A2A9006B021C /* SentryBreadcrumb+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 92672BB529C9A2A9006B021C /* SentryBreadcrumb+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -741,6 +739,7 @@
741739
92D957732E05A44600E20E66 /* SentryAsyncLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 92D957722E05A44600E20E66 /* SentryAsyncLog.m */; };
742740
92D957772E05A4F300E20E66 /* SentryAsyncLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 92D957762E05A4F300E20E66 /* SentryAsyncLog.h */; };
743741
92E5F3D62CDBB3BF00B7AD98 /* SentrySampling.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E8C57A525EEFC42001CEEFA /* SentrySampling.h */; };
742+
92EC54CE2E1EB54B00A10AC2 /* SentryClient+Logs.h in Headers */ = {isa = PBXBuildFile; fileRef = 92EC54CD2E1EB54B00A10AC2 /* SentryClient+Logs.h */; };
744743
92ECD7202E05A7DF0063EC10 /* SentryLogC.h in Headers */ = {isa = PBXBuildFile; fileRef = D8AE48B12C5786AA0092A2A6 /* SentryLogC.h */; settings = {ATTRIBUTES = (Private, ); }; };
745744
92ECD73C2E05ACE00063EC10 /* SentryLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92ECD73B2E05ACDE0063EC10 /* SentryLog.swift */; };
746745
92ECD73E2E05AD320063EC10 /* SentryLogLevel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92ECD73D2E05AD2B0063EC10 /* SentryLogLevel.swift */; };
@@ -2129,8 +2128,6 @@
21292128
92235CAB2E15369900865983 /* SentryLogBatcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogBatcher.swift; sourceTree = "<group>"; };
21302129
92235CAD2E15549C00865983 /* SentryLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogger.swift; sourceTree = "<group>"; };
21312130
92235CAF2E155B2600865983 /* SentryLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLoggerTests.swift; sourceTree = "<group>"; };
2132-
92622E082EABB71000ABE7FF /* SentryLogSPMTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogSPMTests.swift; sourceTree = "<group>"; };
2133-
92622E132EABBDA900ABE7FF /* SentryLog+SPM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryLog+SPM.swift"; sourceTree = "<group>"; };
21342131
9241AC132EBA38CB00E611ED /* SentrySwiftLog.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SentrySwiftLog.framework; sourceTree = BUILT_PRODUCTS_DIR; };
21352132
9241AC1B2EBA38CC00E611ED /* SentrySwiftLogTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SentrySwiftLogTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
21362133
9241AC4A2EBA39EE00E611ED /* SentryLogHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogHandler.swift; sourceTree = "<group>"; };
@@ -2148,6 +2145,7 @@
21482145
92B6BDAC2E05B9F700D538B3 /* SentryLogTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogTests.swift; sourceTree = "<group>"; };
21492146
92D957722E05A44600E20E66 /* SentryAsyncLog.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryAsyncLog.m; sourceTree = "<group>"; };
21502147
92D957762E05A4F300E20E66 /* SentryAsyncLog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryAsyncLog.h; path = include/SentryAsyncLog.h; sourceTree = "<group>"; };
2148+
92EC54CD2E1EB54B00A10AC2 /* SentryClient+Logs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryClient+Logs.h"; path = "include/SentryClient+Logs.h"; sourceTree = "<group>"; };
21512149
92ECD73B2E05ACDE0063EC10 /* SentryLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLog.swift; sourceTree = "<group>"; };
21522150
92ECD73D2E05AD2B0063EC10 /* SentryLogLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogLevel.swift; sourceTree = "<group>"; };
21532151
92ECD73F2E05AD500063EC10 /* SentryLogAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLogAttribute.swift; sourceTree = "<group>"; };
@@ -2766,7 +2764,6 @@
27662764
84B0E0062CD963F9007FB332 /* SentryIconography.swift */,
27672765
621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */,
27682766
F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */,
2769-
92622E132EABBDA900ABE7FF /* SentryLog+SPM.swift */,
27702767
F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */,
27712768
);
27722769
path = Helper;
@@ -3692,7 +3689,6 @@
36923689
F4A930242E661856006DA6EF /* SentryMobileProvisionParserTests.swift */,
36933690
D4F7BD7C2E4373BB004A2D77 /* SentryLevelMapperTests.swift */,
36943691
D8AE48BE2C578D540092A2A6 /* SentrySDKLog.swift */,
3695-
92622E082EABB71000ABE7FF /* SentryLogSPMTests.swift */,
36963692
849AC3FF29E0C1FF00889C16 /* SentryFormatterTests.swift */,
36973693
7B88F30324BC8E6500ADF90A /* SentrySerializationTests.swift */,
36983694
62F4DDA02C04CB9700588890 /* SentryBaggageSerializationTests.swift */,
@@ -5321,6 +5317,7 @@
53215317
8E7C98312693E1CC00E6336C /* SentryTraceHeader.h in Headers */,
53225318
62C316812B1F2E93000D7031 /* SentryDelayedFramesTracker.h in Headers */,
53235319
92D957772E05A4F300E20E66 /* SentryAsyncLog.h in Headers */,
5320+
92EC54CE2E1EB54B00A10AC2 /* SentryClient+Logs.h in Headers */,
53245321
7B8713AE26415ADF006D6004 /* SentryAppStartTrackingIntegration.h in Headers */,
53255322
7B7D873224864BB900D2ECFF /* SentryCrashMachineContextWrapper.h in Headers */,
53265323
861265F92404EC1500C4AFDE /* SentryArray.h in Headers */,
@@ -6272,7 +6269,6 @@
62726269
7B14089824878F950035403D /* SentryCrashStackEntryMapper.m in Sources */,
62736270
D8BC28C82BFF5EBB0054DA4D /* SentryTouchTracker.swift in Sources */,
62746271
63FE711720DA4C1000CDBAE8 /* SentryCrashStackCursor_Backtrace.c in Sources */,
6275-
92622E142EABBDA900ABE7FF /* SentryLog+SPM.swift in Sources */,
62766272
FA3A42722E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift in Sources */,
62776273
63FE70CB20DA4C1000CDBAE8 /* SentryCrashReportFixer.c in Sources */,
62786274
F4A930232E65FDBF006DA6EF /* SentryMobileProvisionParser.swift in Sources */,
@@ -6382,7 +6378,6 @@
63826378
7BE3C78724472E9800A38442 /* TestRequestManager.swift in Sources */,
63836379
63FE722220DA66EC00CDBAE8 /* SentryCrashJSONCodec_Tests.m in Sources */,
63846380
7B0A5452252311CE00A71716 /* SentryBreadcrumbTests.swift in Sources */,
6385-
92622E092EABB71000ABE7FF /* SentryLogSPMTests.swift in Sources */,
63866381
7BE3C7752445C82300A38442 /* SentryCurrentDateTests.swift in Sources */,
63876382
7B3398672459C4AE00BD9C96 /* SentryEnvelopeRateLimitTests.swift in Sources */,
63886383
8EA9AF492665AC48002771B4 /* SentryPerformanceTrackerTests.swift in Sources */,

SentryTestUtils/Sources/TestClient.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ public class TestClient: SentryClientInternal {
161161
flushInvocations.record(timeout)
162162
}
163163

164-
public var captureLogInvocations = Invocations<(log: SentryLog, scope: Scope)>()
165-
public override func _swiftCaptureLog(_ log: NSObject, with scope: Scope) {
166-
if let castLog = log as? SentryLog {
167-
captureLogInvocations.record((castLog, scope))
168-
}
164+
public var captureLogsDataInvocations = Invocations<(data: Data, count: NSNumber)>()
165+
public override func captureLogsData(_ data: Data, with count: NSNumber) {
166+
captureLogsDataInvocations.record((data, count))
169167
}
170168
}

Sources/Sentry/SentryClient.m

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@
4545

4646
NS_ASSUME_NONNULL_BEGIN
4747

48-
@interface SentryClientInternal () <SentryLogBatcherDelegate>
48+
@interface SentryClientInternal ()
4949

5050
@property (nonatomic, strong) SentryTransportAdapter *transportAdapter;
5151
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;
5252
@property (nonatomic, strong) id<SentryRandomProtocol> random;
5353
@property (nonatomic, strong) NSLocale *locale;
5454
@property (nonatomic, strong) NSTimeZone *timezone;
55-
@property (nonatomic, strong) SentryLogBatcher *logBatcher;
5655

5756
@end
5857

@@ -115,10 +114,6 @@ - (instancetype)initWithOptions:(SentryOptions *)options
115114
self.locale = locale;
116115
self.timezone = timezone;
117116
self.attachmentProcessors = [[NSMutableArray alloc] init];
118-
self.logBatcher = [[SentryLogBatcher alloc]
119-
initWithOptions:options
120-
dispatchQueue:SentryDependencyContainer.sharedInstance.dispatchQueueWrapper
121-
delegate:self];
122117

123118
// The SDK stores the installationID in a file. The first call requires file IO. To avoid
124119
// executing this on the main thread, we cache the installationID async here.
@@ -624,11 +619,7 @@ - (SentryEvent *_Nullable)prepareEvent:(SentryEvent *)event
624619

625620
- (void)flush:(NSTimeInterval)timeout
626621
{
627-
NSTimeInterval captureLogsDuration = [self.logBatcher captureLogs];
628-
// Capturing batched logs should never take long, but we need to fall back to a sane value.
629-
// This is a workaround for in-memory logs, until we'll write batched logs to disk,
630-
// to avoid data loss due to crashes. This is a trade-off until then.
631-
[self.transportAdapter flush:fmax(timeout / 2, timeout - captureLogsDuration)];
622+
[self.transportAdapter flush:timeout];
632623
}
633624

634625
- (void)close
@@ -1098,14 +1089,7 @@ - (void)removeAttachmentProcessor:(id<SentryClientAttachmentProcessor>)attachmen
10981089
return processedAttachments;
10991090
}
11001091

1101-
- (void)_swiftCaptureLog:(NSObject *)log withScope:(SentryScope *)scope
1102-
{
1103-
if ([log isKindOfClass:[SentryLog class]]) {
1104-
[self.logBatcher addLog:(SentryLog *)log scope:scope];
1105-
}
1106-
}
1107-
1108-
- (void)captureLogsData:(NSData *)data with:(NSNumber *)itemCount
1092+
- (void)captureLogsData:(NSData *)data with:(NSNumber *)itemCount;
11091093
{
11101094
SentryEnvelopeItemHeader *header =
11111095
[[SentryEnvelopeItemHeader alloc] initWithType:SentryEnvelopeItemTypes.log

Sources/Sentry/SentryHub.m

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
NS_ASSUME_NONNULL_BEGIN
2828

29-
@interface SentryHubInternal () <SentryLoggerDelegate>
29+
@interface SentryHubInternal ()
3030

3131
@property (nullable, atomic, strong) SentryClientInternal *client;
3232
@property (nullable, nonatomic, strong) SentryScope *scope;
@@ -73,10 +73,6 @@ - (instancetype)initWithClient:(nullable SentryClientInternal *)client
7373
if (_scope) {
7474
[_crashWrapper enrichScope:SENTRY_UNWRAP_NULLABLE(SentryScope, _scope)];
7575
}
76-
77-
__swiftLogger = [[SentryLogger alloc]
78-
initWithDelegate:self
79-
dateProvider:SentryDependencyContainer.sharedInstance.dateProvider];
8076
}
8177

8278
return self;
@@ -837,35 +833,6 @@ - (void)unregisterSessionListener:(id<SentrySessionListener>)listener
837833
}
838834
}
839835

840-
// SentryLoggerDelegate
841-
842-
- (void)captureLog:(SentryLog *)log
843-
{
844-
SentryClientInternal *client = self.client;
845-
if (client == nil) {
846-
SENTRY_LOG_WARN(@"No client configured. Dropping log.");
847-
return;
848-
}
849-
#if SENTRY_TARGET_REPLAY_SUPPORTED
850-
NSString *scopeReplayId = self.scope.replayId;
851-
if (scopeReplayId != nil) {
852-
// Session mode: use scope replay ID
853-
[log setAttribute:[[SentryLogAttribute alloc] initWithString:scopeReplayId]
854-
forKey:@"sentry.replay_id"];
855-
} else {
856-
// Buffer mode: check if hub has a session replay ID
857-
NSString *sessionReplayId = [self getSessionReplayId];
858-
if (sessionReplayId != nil) {
859-
[log setAttribute:[[SentryLogAttribute alloc] initWithString:sessionReplayId]
860-
forKey:@"sentry.replay_id"];
861-
[log setAttribute:[[SentryLogAttribute alloc] initWithBoolean:YES]
862-
forKey:@"sentry._internal.replay_is_buffering"];
863-
}
864-
}
865-
#endif
866-
[client _swiftCaptureLog:log withScope:self.scope];
867-
}
868-
869836
#pragma mark - Protected
870837

871838
- (NSArray<NSString *> *)trimmedInstalledIntegrationNames

Sources/Sentry/SentrySDKInternal.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ + (void)close
667667

668668
[SentrySDKInternal setCurrentHub:nil];
669669

670+
[SentrySDK clearLogger];
671+
670672
[SentryDependencyContainer.sharedInstance.crashWrapper stopBinaryImageCache];
671673
[SentryDependencyContainer.sharedInstance.binaryImageCache stop];
672674

Sources/Sentry/include/SentryClient+Private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ NS_ASSUME_NONNULL_BEGIN
7878
- (void)addAttachmentProcessor:(id<SentryClientAttachmentProcessor>)attachmentProcessor;
7979
- (void)removeAttachmentProcessor:(id<SentryClientAttachmentProcessor>)attachmentProcessor;
8080

81-
- (void)_swiftCaptureLog:(NSObject *)log withScope:(SentryScope *)scope;
82-
8381
@end
8482

8583
NS_ASSUME_NONNULL_END

Sources/Sentry/include/SentryHub+Private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
2929

3030
@property (nonatomic, strong) NSMutableArray<id<SentryIntegrationProtocol>> *installedIntegrations;
3131

32-
@property (nonatomic, readonly, strong) NSObject *_swiftLogger;
33-
3432
/**
3533
* Every integration starts with "Sentry" and ends with "Integration". To keep the payload of the
3634
* event small we remove both.

Sources/Sentry/include/SentryPrivate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#import "SentryANRTrackerV1.h"
2929
#import "SentryANRTrackerV2.h"
3030
#import "SentryAsyncLog.h"
31+
#import "SentryClient+Logs.h"
3132
#import "SentryContinuousProfiler.h"
3233
#import "SentryCrash.h"
3334
#import "SentryCrashDebug.h"

Sources/Swift/Helper/SentryLog+SPM.swift

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)