-
-
Notifications
You must be signed in to change notification settings - Fork 378
Log Integrations: Add SentrySwiftyBeaver Integration
#7021
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 all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
8f396d4
Add `SenrtySwiftLog` integration
denrase 2e79d06
Add default `swift package init` .gitignore
denrase c3a610e
Merge branch 'main' into feat/add-swift-log-integration
denrase 9fdbc39
Add ci job to run test
denrase b096852
Add files-changed gate
denrase d1851a8
Merge branch 'main' into feat/add-swift-log-integration
denrase 5a72187
update folder structure
denrase 2077ce0
update name
denrase 8869b37
Merge branch 'main' into feat/add-swift-log-integration
denrase 20dd7d9
ranem folder
denrase ba00c98
uypdate .gitignore
denrase 8e76c5d
add a note to readme
denrase 0f5f086
Merge branch 'main' into feat/add-swift-log-integration
denrase aa78095
update readme
denrase aa2c11c
Merge branch 'main' into feat/add-swift-log-integration
denrase 6106fab
add comment
denrase abc21c7
Add `SentrySwiftyBeaver` Integration
denrase 9c6f0d5
remove redundant log level filtering
denrase 49d6872
add test for min level filtering
denrase 1bade41
add test run
denrase 18e2765
Suport bumping of 3rd party Pakcage.swift versions
denrase 6322192
Merge branch 'feat/add-swift-log-integration' into feat/add-swifty-be…
denrase 00a2cc6
Add swiftybeaver package.swift to v update
denrase e55cf9a
don’t test internal switybeaver functionality (run on a queue)
denrase 6006c00
remove un-needed init
denrase 2c09c62
Merge branch 'main' into feat/add-swift-log-integration
denrase 7f8792c
Bump sentry version
denrase 8fab1d8
Merge branch 'main' into feat/add-swift-log-integration
denrase 31008ec
Add check for SentrySDK state in log handler to prevent logging when …
denrase 2c0c39e
Add swiftlog integration unit tests to the CI workflow
denrase f28ac5b
Merge branch 'main' into feat/add-swift-log-integration
denrase b54e2bb
Changed log attribute keys from `swift-log.*` to `code.*` for better …
denrase 828a2b7
Merge branch 'main' into feat/add-swift-log-integration
denrase ba3969b
Update 3rd-party-integrations/SentrySwiftLog/README.md
denrase 0f41df4
Merge branch 'main' into feat/add-swift-log-integration
denrase cd37fe7
Update codecov configuration and AGENTS.md to include 3rd-party integ…
denrase bb53032
Merge branch 'feat/add-swift-log-integration' of github.com:getsentry…
denrase 3a367a3
Merge branch 'feat/add-swift-log-integration' into feat/add-swifty-be…
denrase 17eed44
use correct attributes
denrase f3c2762
add to needs test.yml
denrase 82c5d23
fix merge conflict issue
denrase 0d57a37
Merge branch 'main' into feat/add-swift-log-integration
denrase f119d5e
Merge branch 'feat/add-swift-log-integration' into feat/add-swifty-be…
denrase fbdf666
Update condition for running SentrySwiftLog unit tests in GitHub Acti…
denrase bb0e1f0
Update file filters to include Package.swift for 3rd-party integrations
denrase cb927b6
Merge branch 'feat/add-swift-log-integration' into feat/add-swifty-be…
denrase 0c8b3f4
correct condition
denrase daf454a
Merge branch 'main' into feat/add-swifty-beaver-integration
denrase f9bcb53
Merge branch 'main' into feat/add-swifty-beaver-integration
denrase 5e09949
Merge branch 'main' into feat/add-swifty-beaver-integration
denrase c66eb11
fix current version
denrase 12218b5
Add check for SentrySDK.iSEnabled state before logging
denrase d6fadb7
Merge branch 'main' into feat/add-swifty-beaver-integration
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # --- macOS --- | ||
|
|
||
| # General | ||
| .DS_Store | ||
| __MACOSX/ | ||
| .AppleDouble | ||
| .LSOverride | ||
| Icon[] | ||
|
|
||
| # Thumbnails | ||
| ._* | ||
|
|
||
| # Files that might appear in the root of a volume | ||
| .DocumentRevisions-V100 | ||
| .fseventsd | ||
| .Spotlight-V100 | ||
| .TemporaryItems | ||
| .Trashes | ||
| .VolumeIcon.icns | ||
| .com.apple.timemachine.donotpresent | ||
|
|
||
| # Directories potentially created on remote AFP share | ||
| .AppleDB | ||
| .AppleDesktop | ||
| Network Trash Folder | ||
| Temporary Items | ||
| .apdisk | ||
|
|
||
| # --- Swift --- | ||
|
|
||
| # Xcode | ||
| # | ||
| # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
|
||
| ## User settings | ||
| xcuserdata/ | ||
|
|
||
| ## Obj-C/Swift specific | ||
| *.hmap | ||
|
|
||
| ## App packaging | ||
| *.ipa | ||
| *.dSYM.zip | ||
| *.dSYM | ||
|
|
||
| ## Playgrounds | ||
| timeline.xctimeline | ||
| playground.xcworkspace | ||
|
|
||
| # Swift Package Manager | ||
| # | ||
| # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. | ||
| # Packages/ | ||
| # Package.pins | ||
| # Package.resolved | ||
| # *.xcodeproj | ||
| # | ||
| # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata | ||
| # hence it is not needed unless you have added a package configuration file to your project | ||
| # .swiftpm | ||
|
|
||
| .build/ | ||
|
|
||
| # CocoaPods | ||
| # | ||
| # We recommend against adding the Pods directory to your .gitignore. However | ||
| # you should judge for yourself, the pros and cons are mentioned at: | ||
| # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
| # | ||
| # Pods/ | ||
| # | ||
| # Add this line if you want to avoid checking in source code from the Xcode workspace | ||
| # *.xcworkspace | ||
|
|
||
| # Carthage | ||
| # | ||
| # Add this line if you want to avoid checking in source code from Carthage dependencies. | ||
| # Carthage/Checkouts | ||
|
|
||
| Carthage/Build/ | ||
|
|
||
| # fastlane | ||
| # | ||
| # It is recommended to not store the screenshots in the git repo. | ||
| # Instead, use fastlane to re-generate the screenshots whenever they are needed. | ||
| # For more information about the recommended setup visit: | ||
| # https://docs.fastlane.tools/best-practices/source-control/#source-control | ||
|
|
||
| fastlane/report.xml | ||
| fastlane/Preview.html | ||
| fastlane/screenshots/**/*.png | ||
| fastlane/test_output | ||
|
|
||
| # --- Xcode --- | ||
|
|
||
| ## User settings | ||
| xcuserdata/ | ||
|
|
||
| # Archive | ||
| *.xcarchive |
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,34 @@ | ||
| // swift-tools-version:6.0 | ||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "SentrySwiftyBeaver", | ||
| platforms: [.iOS(.v15), .macOS(.v10_14), .tvOS(.v15), .watchOS(.v8), .visionOS(.v1)], | ||
| products: [ | ||
| .library( | ||
| name: "SentrySwiftyBeaver", | ||
| targets: ["SentrySwiftyBeaver"] | ||
| ) | ||
| ], | ||
| dependencies: [ | ||
| .package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.1.0"), | ||
| .package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver.git", from: "2.0.0") | ||
| ], | ||
| targets: [ | ||
| .target( | ||
| name: "SentrySwiftyBeaver", | ||
| dependencies: [ | ||
| .product(name: "Sentry", package: "sentry-cocoa"), | ||
| .product(name: "SwiftyBeaver", package: "SwiftyBeaver") | ||
| ] | ||
| ), | ||
| .testTarget( | ||
| name: "SentrySwiftyBeaverTests", | ||
| dependencies: [ | ||
| "SentrySwiftyBeaver", | ||
| .product(name: "Sentry", package: "sentry-cocoa"), | ||
| .product(name: "SwiftyBeaver", package: "SwiftyBeaver") | ||
| ] | ||
| ) | ||
| ] | ||
| ) |
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,116 @@ | ||
| # Sentry SwiftyBeaver Integration | ||
|
|
||
| A [SwiftyBeaver](https://github.com/SwiftyBeaver/SwiftyBeaver) destination that forwards log entries to Sentry's structured logging system, automatically capturing application logs with full context including metadata, source location, and log levels. | ||
|
|
||
| > [!NOTE] | ||
| > This repo is a mirror of [github.com/getsentry/sentry-cocoa](https://github.com/getsentry/sentry-cocoa). The source code lives in `3rd-party-integrations/SentrySwiftyBeaver/`. This allows users to import only what they need via SPM while keeping all integration code in the main repository. | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Swift Package Manager | ||
|
|
||
| Add the following dependencies to your `Package.swift` or Xcode package dependencies: | ||
|
|
||
| ```swift | ||
| dependencies: [ | ||
| .package(url: "https://github.com/getsentry/sentry-cocoa-swiftybeaver", from: "9.0.0") | ||
| ] | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```swift | ||
| import Sentry | ||
| import SwiftyBeaver | ||
|
|
||
| SentrySDK.start { options in | ||
| options.dsn = "YOUR_DSN" | ||
| options.logsEnabled = true | ||
| } | ||
|
|
||
| let log = SwiftyBeaver.self | ||
| let sentryDestination = SentryDestination() | ||
| log.addDestination(sentryDestination) | ||
|
|
||
| log.info("User logged in", context: ["userId": "12345", "sessionId": "abc"]) | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Log Level Threshold | ||
|
|
||
| SwiftyBeaver automatically filters log messages based on each destination's `minLevel` property. Set `minLevel` to control which messages are sent to Sentry. | ||
|
|
||
| ```swift | ||
| let sentryDestination = SentryDestination() | ||
| sentryDestination.minLevel = .error | ||
| log.addDestination(sentryDestination) | ||
| ``` | ||
|
|
||
| ## Log Level Mapping | ||
|
|
||
| SwiftyBeaver levels are automatically mapped to Sentry log levels: | ||
|
|
||
| | SwiftyBeaver Level | Sentry Log Level | | ||
| | ------------------ | ---------------- | | ||
| | `.verbose` | `.trace` | | ||
| | `.debug` | `.debug` | | ||
| | `.info` | `.info` | | ||
| | `.warning` | `.warn` | | ||
| | `.error` | `.error` | | ||
| | `.critical` | `.fatal` | | ||
| | `.fault` | `.fatal` | | ||
|
|
||
| ## Context Handling | ||
|
|
||
| The destination supports SwiftyBeaver's `context` parameter for additional metadata: | ||
|
|
||
| ### Dictionary Context | ||
|
|
||
| When `context` is provided as a `[String: Any]` dictionary, each key-value pair is added as an individual Sentry log attribute with the prefix `swiftybeaver.context.{key}`. | ||
|
|
||
| ```swift | ||
| log.info("User action", context: [ | ||
| "userId": "12345", | ||
| "action": "purchase", | ||
| "isActive": true, | ||
| "errorCode": 500, | ||
| "amount": 99.99 | ||
| ]) | ||
| ``` | ||
|
|
||
| Supported types in dictionary context: | ||
|
|
||
| - Strings | ||
| - Numbers (Int, Double, Float) | ||
| - Booleans | ||
| - Arrays (converted to string representation) | ||
|
|
||
| ### Non-Dictionary Context | ||
|
|
||
| For non-dictionary contexts, the entire context is converted to a string attribute `swiftybeaver.context`. | ||
|
|
||
| ```swift | ||
| log.info("Test message", context: "simple string context") | ||
| ``` | ||
|
|
||
| ## Automatic Attributes | ||
|
|
||
| The destination automatically includes the following attributes with every log entry: | ||
|
|
||
| - `sentry.origin`: `"auto.logging.swiftybeaver"` | ||
| - `swiftybeaver.level`: The original SwiftyBeaver level (as raw value) | ||
| - `swiftybeaver.thread`: The thread identifier | ||
| - `code.file.path`: The source file name | ||
| - `code.function.name`: The function name | ||
| - `code.line.number`: The line number | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [Sentry Cocoa SDK Documentation](https://docs.sentry.io/platforms/apple/) | ||
| - [Sentry Logs Documentation](https://docs.sentry.io/platforms/apple/logs/) | ||
| - [SwiftyBeaver Repo](https://github.com/SwiftyBeaver/SwiftyBeaver) | ||
|
|
||
| ## License | ||
|
|
||
| This integration follows the same license as the Sentry Cocoa SDK. See the [LICENSE](https://github.com/getsentry/sentry-cocoa/blob/main/LICENSE.md) file for details. |
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.