-
-
Notifications
You must be signed in to change notification settings - Fork 372
Flush Logs on WillTerminate or WillResignActive App State
#6909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
be66378
fd55fdf
115a625
71f478e
162273e
3f4813d
aa1fbc9
6cdd1b0
8e36044
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #import "SentryLogFlushIntegration.h" | ||
| #import "SentryClient+Private.h" | ||
| #import "SentryHub.h" | ||
| #import "SentryLogC.h" | ||
| #import "SentrySDK+Private.h" | ||
| #import "SentrySwift.h" | ||
|
|
||
| #if SENTRY_HAS_UIKIT | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Platform mismatch between integration and managerThe Additional Locations (1) |
||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @interface SentryLogFlushIntegration () <SentryAppStateListener> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| @end | ||
|
|
||
| @implementation SentryLogFlushIntegration | ||
|
|
||
| - (BOOL)installWithOptions:(SentryOptions *)options | ||
| { | ||
| if (![super installWithOptions:options]) { | ||
| return NO; | ||
| } | ||
|
|
||
| [[[SentryDependencyContainer sharedInstance] appStateManager] addListener:self]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| return YES; | ||
| } | ||
|
|
||
| - (SentryIntegrationOption)integrationOptions | ||
| { | ||
| return kIntegrationOptionEnableLogs; | ||
| } | ||
|
|
||
| - (void)uninstall | ||
| { | ||
| [[[SentryDependencyContainer sharedInstance] appStateManager] removeListener:self]; | ||
| } | ||
|
|
||
| # pragma mark - SentryAppStateListener | ||
|
|
||
| - (void)appStateManagerWillResignActive | ||
| { | ||
| SentryClientInternal *client = [SentrySDKInternal.currentHub getClient]; | ||
| if (client != nil) { | ||
| [client flushLogs]; | ||
| } | ||
| } | ||
|
|
||
| - (void)appStateManagerWillTerminate | ||
| { | ||
| SentryClientInternal *client = [SentrySDKInternal.currentHub getClient]; | ||
| if (client != nil) { | ||
| [client flushLogs]; | ||
| } | ||
| } | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END | ||
|
|
||
| #endif // SENTRY_HAS_UIKIT | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #import "SentryBaseIntegration.h" | ||
| #import "SentryDefines.h" | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @interface SentryLogFlushIntegration : SentryBaseIntegration | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| @_implementationOnly import _SentryPrivate | ||
| import Foundation | ||
|
|
||
| @_spi(Private) @objc public protocol SentryAppStateListener: NSObjectProtocol { | ||
| @objc optional func appStateManagerWillResignActive() | ||
| @objc optional func appStateManagerWillTerminate() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: If the logBatcher then actually flushes the logs, shouldn't we rename the method toflush?