Updated on 2026-08-14
This commit is contained in:
parent
57421002b1
commit
1c1b913321
4 changed files with 14 additions and 21 deletions
|
|
@ -22,9 +22,11 @@ internal class TangemCardSDKLogger(
|
|||
) : TangemSdkLogger {
|
||||
|
||||
override fun log(message: () -> String, level: Log.Level) {
|
||||
// Disabled for now in [REDACTED_JIRA]
|
||||
// if (!levels.contains(level)) return
|
||||
//
|
||||
// appLogsStore.saveLogMessage(message = messageFormatter.format(message, level))
|
||||
if (!levels.contains(level)) return
|
||||
|
||||
appLogsStore.saveLogMessage(
|
||||
tag = "CardSDK_${level.name}",
|
||||
message = messageFormatter.format(message = message, level = level),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.tap.data
|
|||
|
||||
import com.tangem.blockchain.common.logging.BlockchainSDKLogger
|
||||
import com.tangem.datasource.local.logs.AppLogsStore
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* BlockchainSDK logger implementation
|
||||
|
|
@ -15,6 +16,7 @@ internal class TangemBlockchainSDKLogger(
|
|||
) : BlockchainSDKLogger {
|
||||
|
||||
override fun log(level: BlockchainSDKLogger.Level, message: String) {
|
||||
Timber.d(message)
|
||||
appLogsStore.saveLogMessage(tag = "BlockchainSDK_${level.name}", message)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.datasource.local.logs
|
||||
|
||||
import android.content.Context
|
||||
import com.tangem.datasource.BuildConfig
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.*
|
||||
|
|
@ -34,12 +33,14 @@ class AppLogsStore @Inject constructor(
|
|||
context = SupervisorJob() + dispatchers.io +
|
||||
CoroutineExceptionHandler { _, error -> Timber.e("AppLogsStore.scope is failed $error") },
|
||||
)
|
||||
|
||||
private val mutex = Mutex()
|
||||
private val zipMutex = Mutex()
|
||||
|
||||
private val logFile by lazy {
|
||||
File(applicationContext.filesDir, PERMITTED_FILE_NAME)
|
||||
}
|
||||
|
||||
private val logFileZip by lazy {
|
||||
File(applicationContext.filesDir, PERMITTED_FILE_NAME_ZIP)
|
||||
}
|
||||
|
|
@ -64,7 +65,7 @@ class AppLogsStore @Inject constructor(
|
|||
suspend fun getZipFile(): File? {
|
||||
return zipMutex.withLock {
|
||||
if (logFile.exists()) {
|
||||
zip(listOf(logFile), logFileZip)
|
||||
zip(filesToCompress = listOf(logFile), outputZipFile = logFileZip)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
@ -73,11 +74,6 @@ class AppLogsStore @Inject constructor(
|
|||
|
||||
/** Save log [message] */
|
||||
fun saveLogMessage(tag: String, message: String) {
|
||||
// Temporally logs are not saved in prod environment
|
||||
if (!BuildConfig.TESTER_MENU_ENABLED) {
|
||||
return
|
||||
}
|
||||
|
||||
launchWithLock {
|
||||
createFileIfNotExist()
|
||||
|
||||
|
|
@ -87,11 +83,6 @@ class AppLogsStore @Inject constructor(
|
|||
|
||||
/** Save log that consists from [messages] */
|
||||
fun saveLogMessage(tag: String, vararg messages: String) {
|
||||
// Temporally logs are not saved in prod environment
|
||||
if (!BuildConfig.TESTER_MENU_ENABLED) {
|
||||
return
|
||||
}
|
||||
|
||||
launchWithLock {
|
||||
createFileIfNotExist()
|
||||
|
||||
|
|
@ -139,9 +130,8 @@ class AppLogsStore @Inject constructor(
|
|||
private fun launchWithLock(callback: () -> Unit) {
|
||||
scope.launch {
|
||||
mutex.withLock {
|
||||
runCatching {
|
||||
callback()
|
||||
}.onFailure(Timber::e)
|
||||
runCatching { callback() }
|
||||
.onFailure(Timber::e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ class SendFeedbackEmailUseCase(
|
|||
address = getAddress(type),
|
||||
subject = emailSubjectResolver.resolve(type),
|
||||
message = createMessage(type),
|
||||
// Temporally user data is not sent
|
||||
file = null, // feedbackRepository.getZipLogFile(),
|
||||
file = feedbackRepository.getZipLogFile(),
|
||||
)
|
||||
|
||||
feedbackRepository.sendEmail(email)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue