Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ public struct SentrySDKWrapper {
}
#endif // !os(macOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)

options.enableLogs = true

// Experimental features
options.experimental.enableFileManagerSwizzling = !SentrySDKOverrides.Other.disableFileManagerSwizzling.boolValue
options.experimental.enableUnhandledCPPExceptionsV2 = true
options.experimental.enableLogs = true
}

func configureInitialScope(scope: Scope, options: Options) -> Scope {
Expand Down
7 changes: 7 additions & 0 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ NS_SWIFT_NAME(Options)
*/
@property (nullable, nonatomic, copy) SentryBeforeSendSpanCallback beforeSendSpan NS_SWIFT_SENDABLE;

/**
* When enabled, the SDK sends logs to Sentry. Logs can be captured using the @c SentrySDK.logger
* API, which provides structured logging with attributes.
* @note Default value is @c NO .
*/
@property (nonatomic, assign) BOOL enableLogs;

#if !SWIFT_PACKAGE
/**
* Use this callback to drop or modify a log before the SDK sends it to Sentry. Return @c nil to
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ - (instancetype)init
self.enableNetworkTracking = YES;
self.enableFileIOTracing = YES;
self.enableNetworkBreadcrumbs = YES;
self.enableLogs = NO;
self.tracesSampleRate = nil;
#if SENTRY_TARGET_PROFILING_SUPPORTED
# if !SDK_V9
Expand Down
2 changes: 1 addition & 1 deletion Sources/Swift/Helper/SentrySDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import Foundation
}
let hub = SentryDependencyContainerSwiftHelper.currentHub()
var batcher: SentryLogBatcher?
if let client = hub.getClient(), client.options.experimental.enableLogs {
if let client = hub.getClient(), client.options.enableLogs {
batcher = SentryLogBatcher(client: client, dispatchQueue: Dependencies.dispatchQueueWrapper)
}
let logger = SentryLogger(
Expand Down
5 changes: 0 additions & 5 deletions Sources/Swift/SentryExperimentalOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public class SentryExperimentalOptions: NSObject {
*/
public var enableUnhandledCPPExceptionsV2 = false

/**
* Logs are considered beta.
*/
public var enableLogs = false

@_spi(Private) public func validateOptions(_ options: [String: Any]?) {
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentryLogBatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class SentryLogBatcherTests: XCTestCase {
super.setUp()

options = Options()
options.experimental.enableLogs = true
options.enableLogs = true

testClient = TestClient(options: options)
testDispatchQueue = TestSentryDispatchQueueWrapper()
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentryLoggerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ final class SentryLoggerTests: XCTestCase {
}

func testCaptureLog_SetsTraceIdFromPropagationContext() {
fixture.options.experimental.enableLogs = true
fixture.options.enableLogs = true

let expectedTraceId = SentryId()
let propagationContext = SentryPropagationContext(trace: expectedTraceId, spanId: SpanId())
Expand Down
6 changes: 3 additions & 3 deletions Tests/SentryTests/SentrySDKInternalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@
SentrySDK.resumeAppHangTracking()
Dynamic(anrTrackingIntegration).anrDetectedWithType(SentryANRType.unknown)

XCTAssertEqual(1, client.captureEventWithScopeInvocations.count, "The SDK should capture an AppHang after resuming the tracking, but it didn't.")

Check failure on line 610 in Tests/SentryTests/SentrySDKInternalTests.swift

View workflow job for this annotation

GitHub Actions / Unit iOS 26 Sentry

testResumeAndPauseAppHangTracking, XCTAssertEqual failed: ("1") is not equal to ("0") - The SDK should capture an AppHang after resuming the tracking, but it didn't.

Check failure on line 610 in Tests/SentryTests/SentrySDKInternalTests.swift

View workflow job for this annotation

GitHub Actions / Unit iOS 18 Sentry

testResumeAndPauseAppHangTracking, XCTAssertEqual failed: ("1") is not equal to ("0") - The SDK should capture an AppHang after resuming the tracking, but it didn't.
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
Expand Down Expand Up @@ -701,7 +701,7 @@

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func testLogger_WithLogsEnabled_CapturesLog() {
fixture.client.options.experimental.enableLogs = true
fixture.client.options.enableLogs = true
givenSdkWithHub()

SentrySDK.logger.error(String(repeating: "S", count: 1_024 * 1_024))
Expand All @@ -716,7 +716,7 @@
}

func testLogger_WithNoClient_DoesNotCaptureLog() {
fixture.client.options.experimental.enableLogs = true
fixture.client.options.enableLogs = true
let hubWithoutClient = SentryHub(client: nil, andScope: nil)
SentrySDKInternal.setCurrentHub(hubWithoutClient)

Expand All @@ -733,7 +733,7 @@

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func testLogger_WithLogsDisabled_DoesNotCaptureLog() {
fixture.client.options.experimental.enableLogs = false
fixture.client.options.enableLogs = false
givenSdkWithHub()

SentrySDK.logger.error("foo")
Expand Down
8 changes: 4 additions & 4 deletions Tests/SentryTests/SentrySDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class SentrySDKTests: XCTestCase {
// MARK: - Logger Flush Tests

func testFlush_CallsLoggerCaptureLogs() {
fixture.client.options.experimental.enableLogs = true
fixture.client.options.enableLogs = true
SentrySDKInternal.setCurrentHub(fixture.hub)
SentrySDKInternal.setStart(with: fixture.client.options)

Expand All @@ -462,7 +462,7 @@ class SentrySDKTests: XCTestCase {
}

func testClose_CallsLoggerCaptureLogs() {
fixture.client.options.experimental.enableLogs = true
fixture.client.options.enableLogs = true
SentrySDKInternal.setCurrentHub(fixture.hub)
SentrySDKInternal.setStart(with: fixture.client.options)

Expand All @@ -484,7 +484,7 @@ class SentrySDKTests: XCTestCase {
let loggerBeforeStart = SentrySDK.logger

// Now properly start the SDK using internal APIs
fixture.client.options.experimental.enableLogs = true
fixture.client.options.enableLogs = true
SentrySDKInternal.setCurrentHub(fixture.hub)
SentrySDKInternal.setStart(with: fixture.client.options)

Expand All @@ -506,7 +506,7 @@ class SentrySDKTests: XCTestCase {

func testLogger_WhenLogsDisabled() {
// Start SDK with logs disabled
fixture.client.options.experimental.enableLogs = false
fixture.client.options.enableLogs = false
SentrySDKInternal.setCurrentHub(fixture.hub)
SentrySDKInternal.setStart(with: fixture.client.options)

Expand Down
Loading
Loading