Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a64ff19
Move SentryAsyncLogWrapper out of SentryLogC.h. Move `SenryLog.c` dec…
denrase Jun 20, 2025
807cb7e
Update visibility to private
denrase Jun 20, 2025
f630a8b
Rename SentryLog to SentryLogSwift
denrase Jun 20, 2025
8749842
Rename file
denrase Jun 20, 2025
e668737
remove unused SentryLogLevel in defines
denrase Jun 20, 2025
f441b96
Add log models and serialization/deserialization tests
denrase Jun 20, 2025
e8851ad
addadd cl entry
denrase Jun 20, 2025
4b2981c
Rename `SentrLogSwift` to SentrySDKLog
denrase Jun 24, 2025
3cd7e3b
remove duplicate imports
denrase Jun 24, 2025
d10a5c2
Rename SentryLogLevel to SentryLog.Level and restore previous ObjC Se…
denrase Jun 24, 2025
05a9399
Merge branch 'main' into feat/structured-logs-models
denrase Jun 24, 2025
cbb641c
Use new naming
denrase Jun 24, 2025
9b61085
rename files
denrase Jun 24, 2025
238bf17
Add docs link to toSeverityNumber()
denrase Jun 24, 2025
6074420
Rename SentryLogAttribute to SentryLog.Attribute and change it to an …
denrase Jun 24, 2025
39c2e9e
Add encodeToJSONData helper with correct date encoding strategy
denrase Jun 24, 2025
6cd8671
Fix failing SentrySDKLogTests
denrase Jun 24, 2025
dddb9dd
run clang format
denrase Jun 24, 2025
d36a441
run swiftlint —fix
denrase Jun 24, 2025
ad20321
remove new sentry log classes
denrase Jun 24, 2025
1d89693
Revert "remove new sentry log classes"
denrase Jun 24, 2025
c5a365e
update cl
denrase Jun 25, 2025
50fa3e3
Merge branch 'main' into feat/structured-logs-models
denrase Jun 26, 2025
ddf7abf
fix cl
denrase Jun 26, 2025
c461f7f
cleanup
denrase Jun 26, 2025
43f0736
format
denrase Jun 26, 2025
3eeb816
Merge branch 'main' into feat/structured-logs-models
denrase Jun 27, 2025
bfe2a69
fix project file
denrase Jun 27, 2025
a06a3da
Merge branch 'main' into feat/structured-logs-models
denrase Jun 30, 2025
f3a910e
fix cl
denrase Jun 30, 2025
005e3c6
Merge branch 'main' into feat/structured-logs-models
denrase Jul 1, 2025
ad54f0b
remove cl entry
denrase Jul 1, 2025
542a919
add sev tests
denrase Jul 1, 2025
0e65135
use XCTUnwrap instead of XCTAssertNotNil
denrase Jul 1, 2025
605f164
make encode funcs internal
denrase Jul 1, 2025
548eb4e
remove separate codable files
denrase Jul 1, 2025
0484a04
dont use forece unwraps in tests
denrase Jul 1, 2025
5a8661a
use double instead of
denrase Jul 1, 2025
124d3e3
run swift lint fix
denrase Jul 1, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

- Capturing fatal CPPExceptions via hooking into cxa_throw when enabling `options.experimental.enableUnhandledCPPExceptionsV2 = true` (#5256)
- [Structured Logging] Models + Preparation ([#5441](https://github.com/getsentry/sentry-cocoa/pull/5441))

### Fixes

Expand Down
92 changes: 71 additions & 21 deletions Sentry.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SentryTestUtils/ClearTestState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TestCleanup: NSObject {
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = false
SentryNetworkTracker.sharedInstance.disable()

SentryLog.setDefaultTestLogConfiguration()
SentryLogSwift.setDefaultTestLogConfiguration()

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)

Expand Down
6 changes: 3 additions & 3 deletions SentryTestUtils/SentryLogExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Foundation
@_spi(Private) @testable import Sentry

extension SentryLog {
extension SentryLogSwift {

public static func setDefaultTestLogConfiguration() {
SentryLog._configure(false, diagnosticLevel: .error)
SentryLogSwift._configure(false, diagnosticLevel: .error)
}

/// SentryLog uses NSLog internally, which can significantly slow down code because it requires
/// synchronization. Use this method sparingly for individual test cases.
public static func withDebugLogs<T>(_ closure: () throws -> T) rethrows -> T {
defer { setDefaultTestLogConfiguration() }
SentryLog._configure(true, diagnosticLevel: .debug)
SentryLogSwift._configure(true, diagnosticLevel: .debug)
return try closure()
}

Expand Down
2 changes: 1 addition & 1 deletion SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#import "SentryGlobalEventProcessor.h"
#import "SentryHub+Private.h"
#import "SentryHub+Test.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryNSNotificationCenterWrapper.h"
#import "SentryNSProcessInfoWrapper.h"
#import "SentryNSTimerFactory.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentryWatchdogTerminationBreadcrumbProcessor.h"
#import "SentryFileManager.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentrySerialization.h"

@interface SentryWatchdogTerminationBreadcrumbProcessor ()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Profiling/SentryContinuousProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# import "SentryDependencyContainer.h"
# import "SentryDispatchQueueWrapper.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryMetricProfiler.h"
# import "SentryNSNotificationCenterWrapper.h"
# import "SentryNSTimerFactory.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# import "SentryFileManager.h"
# import "SentryInternalDefines.h"
# import "SentryLaunchProfiling.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfiler+Private.h"
# import "SentryRandom.h"
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# import "SentryContinuousProfiler.h"
# import "SentryInternalDefines.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfiler+Private.h"
# import "SentrySwift.h"
Expand All @@ -16,7 +16,7 @@
# import "SentryHub+Private.h"
# import "SentryInternalDefines.h"
# import "SentryLaunchProfiling.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfiledTracerConcurrency.h"
# import "SentryProfiler+Private.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Profiling/SentryProfilerSerialization.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# import "SentryEvent+Private.h"
# import "SentryFormatter.h"
# import "SentryInternalDefines.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryMeta.h"
# import "SentryMetricProfiler.h"
# import "SentryProfileTimeseries.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Profiling/SentryTraceProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# import "SentryDependencyContainer.h"
# import "SentryDispatchQueueWrapper.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryMetricProfiler.h"
# import "SentryNSTimerFactory.h"
# import "SentryProfiledTracerConcurrency.h"
Expand Down
10 changes: 0 additions & 10 deletions Sources/Sentry/Public/SentryDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,6 @@ typedef NSNumber *_Nullable (^SentryTracesSamplerCallback)(
typedef void (^SentrySpanCallback)(id<SentrySpan> _Nullable span DEPRECATED_MSG_ATTRIBUTE(
"See `SentryScope.useSpan` for reasoning of deprecation."));

/**
* Log level.
*/
typedef NS_ENUM(NSInteger, SentryLogLevel) {
kSentryLogLevelNone = 1,
kSentryLogLevelError,
kSentryLogLevelDebug,
kSentryLogLevelVerbose
};

/**
* Sentry level.
*/
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryANRTrackerV1.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "SentryCrashWrapper.h"
#import "SentryDependencyContainer.h"
#import "SentryDispatchQueueWrapper.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentrySwift.h"
#import "SentryThreadWrapper.h"
#import <stdatomic.h>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryANRTrackerV2.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# import "SentryDependencyContainer.h"
# import "SentryDispatchQueueWrapper.h"
# import "SentryFramesTracker.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentrySwift.h"
# import "SentryThreadWrapper.h"
# import "SentryTime.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryANRTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "SentryException.h"
#import "SentryFileManager.h"
#import "SentryHub+Private.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryMechanism.h"
#import "SentrySDK+Private.h"
#import "SentryScope+Private.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAppStartMeasurement.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if SENTRY_UIKIT_AVAILABLE

# import "SentryDateUtils.h"
# import "SentryLog.h"
# import "SentryLogC.h"

@implementation SentryAppStartTypeToString
+ (NSString *)convert:(SentryAppStartType)type
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryAppStartTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# import "SentryAppStateManager.h"
# import "SentryDefines.h"
# import "SentryFramesTracker.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentrySysctl.h"
# import <PrivateSentrySDKOnly.h>
# import <SentryAppState.h>
# import <SentryDependencyContainer.h>
# import <SentryDispatchQueueWrapper.h>
# import <SentryInternalNotificationNames.h>
# import <SentryLog.h>
# import <SentryLogC.h>
# import <SentrySDK+Private.h>
# import <SentrySwift.h>
# import <UIKit/UIKit.h>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAppStartTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if SENTRY_HAS_UIKIT

# import "SentryAppStartTracker.h"
# import "SentryLog.h"
# import "SentryLogC.h"
# import "SentryOptions.h"
# import <PrivateSentrySDKOnly.h>
# import <SentryAppStateManager.h>
Expand Down
24 changes: 24 additions & 0 deletions Sources/Sentry/SentryAsyncLog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef SentryAsyncLog_h
#define SentryAsyncLog_h

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Wrapper for initializing async-safe logging functionality.
* This is used for crash-safe logging that can write to a file even during crashes.
*/
@interface SentryAsyncLogWrapper : NSObject

/**
* Initializes the async log file in the Sentry cache directory.
* This method sets up async-safe logging that can be used during crash scenarios.
*/
+ (void)initializeAsyncLogFile;

@end

NS_ASSUME_NONNULL_END

#endif // SentryAsyncLog_h
32 changes: 32 additions & 0 deletions Sources/Sentry/SentryAsyncLog.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#import "SentryAsyncLog.h"
#import "SentryAsyncSafeLog.h"
#import "SentryFileManager.h"
#import "SentryInternalCDefines.h"
#import "SentryLogC.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SentryAsyncLogWrapper

+ (void)initializeAsyncLogFile
{
const char *asyncLogPath =
[[sentryStaticCachesPath() stringByAppendingPathComponent:@"async.log"] UTF8String];

NSError *error;
if (!createDirectoryIfNotExists(sentryStaticCachesPath(), &error)) {
SENTRY_LOG_ERROR(@"Failed to initialize directory for async log file: %@", error);
return;
}

if (SENTRY_LOG_ERRNO(
sentry_asyncLogSetFileName(asyncLogPath, true /* overwrite existing log */))
!= 0) {
SENTRY_LOG_ERROR(
@"Could not open a handle to specified path for async logging %s", asyncLogPath);
};
}

@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAutoBreadcrumbTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "SentryBreadcrumbTracker.h"
#import "SentryDependencyContainer.h"
#import "SentryFileManager.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryOptions.h"
#import "SentrySDK.h"
#import "SentrySystemEventBreadcrumbs.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAutoSessionTrackingIntegration.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentryAutoSessionTrackingIntegration.h"
#import "SentryDependencyContainer.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryOptions.h"
#import "SentrySDK.h"
#import "SentrySessionTracker.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryBaggage.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentryBaggage.h"
#import "SentryDsn.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryOptions+Private.h"
#import "SentryScope+Private.h"
#import "SentrySwift.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryBaseIntegration.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentryBaseIntegration.h"
#import "SentryCrashWrapper.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentrySwift.h"
#import <SentryDependencyContainer.h>
#import <SentryOptions+Private.h>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryBinaryImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "SentryCrashUUIDConversion.h"
#import "SentryDependencyContainer.h"
#import "SentryInAppLogic.h"
#import "SentryLog.h"
#import "SentryLogC.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryBreadcrumbTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#import "SentryDefines.h"
#import "SentryDependencyContainer.h"
#import "SentryHub.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryReachability.h"
#import "SentryScope.h"
#import "SentrySwift.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#import "SentryHub.h"
#import "SentryInAppLogic.h"
#import "SentryInstallation.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryMechanism.h"
#import "SentryMechanismMeta.h"
#import "SentryMessage.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCoreDataTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "SentryFrame.h"
#import "SentryHub+Private.h"
#import "SentryInternalDefines.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryNSProcessInfoWrapper.h"
#import "SentryPredicateDescriptor.h"
#import "SentrySDK+Private.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCoreDataTrackingIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "SentryCoreDataSwizzling.h"
#import "SentryCoreDataTracker.h"
#import "SentryDependencyContainer.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryNSDataSwizzling.h"
#import "SentryNSProcessInfoWrapper.h"
#import "SentryOptions.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashInstallationReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "SentryCrashInstallation+Private.h"
#import "SentryCrashReportSink.h"
#import "SentryDefines.h"
#import "SentryLog.h"
#import "SentryLogC.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#import <SentryClient+Private.h>
#import <SentryCrashScopeObserver.h>
#import <SentryDependencyContainer.h>
#import <SentryLog.h>
#import <SentryLogC.h>
#import <SentrySDK+Private.h>

#if SENTRY_HAS_UIKIT
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashIntegrationSessionHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#import "SentryDependencyContainer.h"
#import "SentryFileManager.h"
#import "SentryHub.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentrySDK+Private.h"
#import "SentrySession.h"
#import "SentrySwift.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashReportConverter.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "SentryFrame.h"
#import "SentryInAppLogic.h"
#import "SentryInternalDefines.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryMechanism.h"
#import "SentryMechanismMeta.h"
#import "SentryStacktrace.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashReportSink.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "SentryEvent.h"
#import "SentryException.h"
#import "SentryHub.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentrySDK+Private.h"
#import "SentrySDK.h"
#import "SentryScope+Private.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashScopeObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#import <SentryCrashJSONCodec.h>
#import <SentryCrashJSONCodecObjC.h>
#import <SentryCrashScopeObserver.h>
#import <SentryLog.h>
#import <SentryLogC.h>
#import <SentryNSDataUtils.h>
#import <SentryScopeSyncC.h>
#import <SentryUser.h>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryDebugImageProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "SentryFormatter.h"
#import "SentryFrame.h"
#import "SentryInternalDefines.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryStacktrace.h"
#import "SentryThread.h"
#import <Foundation/Foundation.h>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryDefaultRateLimits.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "SentryConcurrentRateLimitsDictionary.h"
#import "SentryDataCategoryMapper.h"
#import "SentryDateUtil.h"
#import "SentryLog.h"
#import "SentryLogC.h"
#import "SentryRateLimitParser.h"
#import "SentryRetryAfterHeaderParser.h"
#import "SentrySwift.h"
Expand Down
Loading
Loading