Skip to content

Commit ef6901c

Browse files
authored
feat: Add Sentry.i overload taking a block (#324)
2 parents 0cb4bdc + e957a4c commit ef6901c

File tree

1 file changed

+12
-0
lines changed
  • Sentry/src/main/kotlin/com/infomaniak/core/sentry

1 file changed

+12
-0
lines changed

Sentry/src/main/kotlin/com/infomaniak/core/sentry/SentryLog.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ object SentryLog {
2828

2929
private val TAG = SentryLog::class.java.simpleName
3030

31+
inline fun <R> i(tag: String, msg: String, block: () -> R): R {
32+
try {
33+
i(tag, "$msg entered")
34+
val result = block()
35+
i(tag, "$msg exited successfully")
36+
return result
37+
} catch (t: Throwable) {
38+
i(tag, "$msg exited with throwable", t)
39+
throw t
40+
}
41+
}
42+
3143
fun v(tag: String, msg: String, throwable: Throwable? = null) {
3244
val formattedMessage = formatLogMessage(tag, msg)
3345
Log.v(TAG, formattedMessage, throwable)

0 commit comments

Comments
 (0)