Commit 67a0fc9
feat(kmp): Add logs (#509)
* Implement SentryLoggerApi for Kotlin Multiplatform with platform-specific loggers for JVM and Apple. Add logging capabilities with structured message formatting and attributes. Update SentryOptions to include log enabling feature. Enhance SentryBridge to provide logger access. Include no-op logger for unsupported platforms.
* Enhance logging capabilities in Kotlin Multiplatform by implementing SentryLoggerApi with structured logging support. Introduce SentryLog and SentryLogOptions for managing log entries and configurations. Update SentryOptions to include logging settings and modify SentryBridge to provide logger access. Add tests for log level conversions and SentryAttributes functionality.
* Refactor logging implementation in Kotlin Multiplatform by replacing SentryLoggerApi with SentryLogger interface. Introduce structured logging capabilities with DefaultSentryLogEventBuilder and SentryLogEventBuilder. Update SentryBridge and platform-specific loggers for improved integration. Remove deprecated SentryLoggerApi and enhance no-op logger for unsupported platforms.
* Implement Cocoa and JVM logging delegates in Kotlin Multiplatform, enhancing structured logging capabilities. Introduce CocoaSentryLoggerDelegate and JvmSentryLogger for platform-specific logging. Update SentryAttributes to use SentryAttributeValue for type-safe attribute handling. Refactor SentryLog and SentryLogOptions for improved log management. Add tests for log level conversions and attribute functionality.
* Refactor logging implementation in Kotlin Multiplatform by introducing a unified logging architecture. Replace CocoaSentryLoggerDelegate and JvmSentryLogger with BaseSentryLogger for shared logic. Enhance SentryAttributes for type-safe attribute handling and update SentryLogBuilder for structured logging. Remove deprecated classes and add comprehensive tests for logging functionality and attribute conversions.
* Enhance Kotlin Multiplatform logging by adding SentryLogger interface and SentryAttributeValue classes for structured logging. Introduce SentryLog and SentryLogOptions for improved log management across platforms. Update SentryOptions to include logging configurations and ensure compatibility with existing attributes. Refactor SentryBridge to provide logger access and improve integration with platform-specific loggers. Add tests for attribute conversions and logging functionality.
* Refactor DefaultSentryLogBuilder by removing commented sections for improved readability and updating the attributes method to include the @SentryLogDsl annotation for better DSL support.
* Update comment
* Revert changes to plugin - accidental change
* API dump
* Fix test
* Fix tests
* Fix tests
* Add structured logging support with attribute DSL functions
* fix(logs): Fix Apple attribute conversion and stale logger references
Apple toKmpSentryAttributes was matching raw types (String, NSNumber)
instead of SentryStructuredLogAttribute objects, causing all attributes
to be silently dropped. Also fix updateAttributesFrom to produce
SentryStructuredLogAttribute instances instead of raw values.
Both JVM and Apple logger adapters now accept a provider function
instead of capturing a logger reference, preventing stale references
after Sentry close/re-init cycles. Fix severityNumber update to
always call setSeverityNumber, allowing users to clear it to null.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add all Sentry.logger API variants to sample app for testing
Covers: simple message with varargs (Variant A), message with inline
attributes lambda (Variant B), full DSL builder with message/attributes
(Variant C), plain message DSL, prebuilt SentryAttributes, and merged
attributes blocks. Exercises all attribute types (String, Int, Boolean,
Double).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Make sample logger messages distinctive across API variants
Each log call now has a unique message following a login flow theme,
making it easy to identify which API variant produced each log entry.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Update tests
* Update CHANGELOG
* Update CHANGELOG
* Update public docs for logger
* Run spotlessApply
* Fix NSInteger type mismatch for 32-bit Apple targets
Use .convert() for Long-to-NSInteger conversion so it works on both
64-bit (Long) and 32-bit (Int) Apple targets.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix MaxLineLength detekt issue and run spotlessApply
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add missing log functions
* Update sample and CHANGELOG
* Update CHANGELOG
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent fa235cc commit 67a0fc9
46 files changed
Lines changed: 3582 additions & 4 deletions
File tree
- config/detekt
- sentry-kotlin-multiplatform
- api
- android
- jvm
- src
- appleMain/kotlin/io/sentry/kotlin/multiplatform
- extensions
- log
- appleTest/kotlin/io/sentry/kotlin/multiplatform
- log
- commonJvmMain/kotlin/io/sentry/kotlin/multiplatform
- extensions
- log
- commonJvmTest/kotlin/io/sentry/kotlin/multiplatform
- log
- commonMain/kotlin/io/sentry/kotlin/multiplatform
- log
- commonStub/kotlin/io/sentry/kotlin/multiplatform
- commonTest/kotlin/io/sentry/kotlin/multiplatform
- log
- sentry-samples
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
3 | 27 | | |
4 | 28 | | |
5 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
231 | 239 | | |
232 | 240 | | |
233 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
Lines changed: 157 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
93 | 168 | | |
94 | 169 | | |
95 | 170 | | |
| |||
181 | 256 | | |
182 | 257 | | |
183 | 258 | | |
| 259 | + | |
184 | 260 | | |
185 | 261 | | |
186 | 262 | | |
| |||
212 | 288 | | |
213 | 289 | | |
214 | 290 | | |
| 291 | + | |
215 | 292 | | |
216 | 293 | | |
217 | 294 | | |
| |||
265 | 342 | | |
266 | 343 | | |
267 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
268 | 425 | | |
269 | 426 | | |
270 | 427 | | |
| |||
0 commit comments