-
-
Notifications
You must be signed in to change notification settings - Fork 372
Structured Logs: Add log APIs to Hub and Client
#6518
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
455e640
Support capturing logs in hub and client
denrase fe496c6
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 79f488f
fix typo
denrase 0a4031e
update tests
denrase 7a38ee2
add documentation
denrase 6f84e05
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 010294f
add cl entry
denrase f376254
update public api
denrase f1e0dc3
relax flush accuracy
denrase e9d6a1e
fix SPM circular dependency issue
denrase b8be304
make new hub/scope selectors available in SPM
denrase e060a58
provide selector protocols outside of swift pkg if/else
denrase ca30a2d
use correct scope parameter, add test
denrase 585893a
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 4d72a5d
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 4533b76
introduce captureLog dispatcher, handle case where it’ll not work and…
denrase 4446d9f
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase f913b46
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 4bd9c2a
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 5220b71
add test for replayid
denrase 2eafc00
remove NS_SWIFT_NAME
denrase 4197873
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase b42d510
fix typo
denrase f00c069
add comment
denrase dee5276
rename
denrase 11031c7
expose sentrylogger on Hub
denrase ebaac6b
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 0239c61
use cast to exose logger
denrase 130e34d
update test
denrase dd00bcb
update access to fw decalered log APIs
denrase ca58453
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase df33907
cleanup
denrase 11f2254
remove mention of logs in beta
denrase ddc8ad7
use _swiftLogger in hub swift
denrase 1ee870f
cleanup
denrase 1fe6bb7
remove redundant test
denrase d7e46ca
update public api
denrase 33d4912
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 0dd1af0
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 0d24147
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 75d3996
Add possibility to mutate log attributes from ObjC, Add heleper metho…
denrase c662522
Move log abtcher delegate to ctor and make it private
denrase a8766e9
make teh delegate non-nil
denrase c6c9bb6
add comment
denrase 26d91ce
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase d5e2104
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase c811a52
update public api
denrase 7510ff6
Merge branch 'denrase/logs-in-hub-and-client' of github.com:getsentry…
denrase d9513b1
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase 1031ebc
pe review feedback
denrase 232820f
update pub api
denrase e8e1d88
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase b86e969
wanr if no client
denrase 04e1373
use noop delegate instead of internal init
denrase f48cef0
update cl
denrase 47d0d41
revert to no-op init
denrase 75e78bc
Merge branch 'main' into denrase/logs-in-hub-and-client
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| @_implementationOnly import _SentryPrivate | ||
| import Foundation | ||
|
|
||
| // Swift extensions to provide properly typed log-related APIs for SPM builds. | ||
| // In SPM builds, SentryLog is only forward declared in the Objective-C headers, | ||
| // causing Swift-to-Objective-C bridging issues. These extensions work around that | ||
| // by providing Swift-native methods and properties that use dynamic dispatch internally. | ||
|
|
||
| @objc | ||
| protocol HubSelectors { | ||
| func captureLog(_ log: SentryLog) | ||
| func captureLog(_ log: SentryLog, withScope: Scope) | ||
| } | ||
|
|
||
| @objc | ||
| protocol ClientSelectors { | ||
| func captureLog(_ log: SentryLog, withScope: Scope) | ||
| } | ||
|
|
||
| #if SWIFT_PACKAGE | ||
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Use this callback to drop or modify a log before the SDK sends it to Sentry. Return `nil` to | ||
| * drop the log. | ||
| */ | ||
| public typealias SentryBeforeSendLogCallback = (SentryLog) -> SentryLog? | ||
|
|
||
| @objc | ||
| public extension Options { | ||
| /** | ||
| * Use this callback to drop or modify a log before the SDK sends it to Sentry. Return `nil` to | ||
| * drop the log. | ||
| */ | ||
| @objc | ||
| var beforeSendLog: SentryBeforeSendLogCallback? { | ||
| get { return value(forKey: "beforeSendLogDynamic") as? SentryBeforeSendLogCallback } | ||
| set { setValue(newValue, forKey: "beforeSendLogDynamic") } | ||
| } | ||
| } | ||
|
|
||
| @objc | ||
| public extension SentryHub { | ||
| /// Captures a log entry and sends it to Sentry. | ||
| /// - Parameter log: The log entry to send to Sentry. | ||
| /// | ||
| /// This method is provided for SPM builds where the Objective-C `captureLog:` method | ||
| /// may not be properly bridged due to `SentryLog` being defined in Swift. | ||
| func capture(log: SentryLog) { | ||
| // Use dynamic dispatch to work around bridging limitations | ||
| perform(#selector(HubSelectors.captureLog(_:)), with: log) | ||
denrase marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// Captures a log entry and sends it to Sentry with a specific scope. | ||
| /// - Parameters: | ||
| /// - log: The log entry to send to Sentry. | ||
| /// - scope: The scope containing event metadata. | ||
| /// | ||
| /// This method is provided for SPM builds where the Objective-C `captureLog:withScope:` method | ||
| /// may not be properly bridged due to `SentryLog` being defined in Swift. | ||
| func capture(log: SentryLog, scope: Scope) { | ||
| // Use dynamic dispatch to work around bridging limitations | ||
| perform(#selector(HubSelectors.captureLog(_:withScope:)), with: log, with: scope) | ||
| } | ||
| } | ||
|
|
||
| /// Extension to provide log capture methods for SPM builds. | ||
| @objc | ||
| public extension SentryClient { | ||
| /// Captures a log entry and sends it to Sentry. | ||
| /// - Parameters: | ||
| /// - log: The log entry to send to Sentry. | ||
| /// - scope: The scope containing event metadata. | ||
| func captureLog(_ log: SentryLog, withScope scope: Scope) { | ||
| // Use dynamic dispatch to work around bridging limitations | ||
| perform(#selector(ClientSelectors.captureLog(_:withScope:)), with: log, with: scope) | ||
| } | ||
| } | ||
|
|
||
| #endif // SWIFT_PACKAGE | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.