Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-20 21:54:46 +04:00
parent 8b75e37e30
commit a9bca131c3
386 changed files with 1369 additions and 1347 deletions

View file

@ -23,6 +23,10 @@ dependencies {
implementation(deps.jodatime)
// endregion
// region Logging
implementation(deps.kermit)
// endregion
testImplementation(deps.test.coroutine)
testImplementation(deps.test.junit5)
testRuntimeOnly(deps.test.junit5.engine)

View file

@ -1,10 +1,9 @@
package com.tangem.utils.coroutines
import com.tangem.utils.logging.TangemLogger
import kotlinx.coroutines.CoroutineExceptionHandler
import java.io.PrintWriter
import java.io.StringWriter
import java.util.logging.Level
import java.util.logging.Logger
/**
[REDACTED_AUTHOR]
@ -16,11 +15,7 @@ object FeatureCoroutineExceptionHandler {
val sw = StringWriter()
throwable.printStackTrace(PrintWriter(sw))
val exceptionAsString: String = sw.toString()
// it delegates logging to android Logger, cause cant use timber in java module
Logger.getLogger("CoroutineExceptHandler").log(
Level.INFO,
"CoroutineException: from: $from, exception: $exceptionAsString",
)
TangemLogger.i("CoroutineException: from: $from, exception: $exceptionAsString")
throw throwable
}
}

View file

@ -0,0 +1,63 @@
package com.tangem.utils.logging
import co.touchlab.kermit.Logger
/**
* Application-level logger that wraps Kermit [Logger] with the same API.
* All modules should use [TangemLogger] instead of importing Kermit directly.
*/
object TangemLogger {
fun v(messageString: String, throwable: Throwable? = null) {
Logger.v(messageString, throwable)
}
fun d(messageString: String, throwable: Throwable? = null) {
Logger.d(messageString, throwable)
}
fun i(messageString: String, throwable: Throwable? = null) {
Logger.i(messageString, throwable)
}
fun w(messageString: String, throwable: Throwable? = null) {
Logger.w(messageString, throwable)
}
fun e(messageString: String, throwable: Throwable? = null) {
Logger.e(messageString, throwable)
}
fun a(messageString: String, throwable: Throwable? = null) {
Logger.a(messageString, throwable)
}
fun withTag(tag: String): TaggedLogger = TaggedLogger(tag)
class TaggedLogger internal constructor(private val tag: String) {
fun v(messageString: String, throwable: Throwable? = null) {
Logger.withTag(tag).v(messageString, throwable)
}
fun d(messageString: String, throwable: Throwable? = null) {
Logger.withTag(tag).d(messageString, throwable)
}
fun i(messageString: String, throwable: Throwable? = null) {
Logger.withTag(tag).i(messageString, throwable)
}
fun w(messageString: String, throwable: Throwable? = null) {
Logger.withTag(tag).w(messageString, throwable)
}
fun e(messageString: String, throwable: Throwable? = null) {
Logger.withTag(tag).e(messageString, throwable)
}
fun a(messageString: String, throwable: Throwable? = null) {
Logger.withTag(tag).a(messageString, throwable)
}
}
}