Updated on 2026-08-14
This commit is contained in:
parent
842b3e494a
commit
e01127186c
14 changed files with 128 additions and 131 deletions
|
|
@ -3,19 +3,19 @@ package com.tangem.tap.common.log
|
|||
import android.util.Log
|
||||
import com.orhanobut.logger.AndroidLogAdapter
|
||||
import com.orhanobut.logger.Logger
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.datasource.local.logs.AppLogsStore
|
||||
import com.tangem.wallet.BuildConfig
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Tangem app logger
|
||||
*
|
||||
* @property settingsRepository repository for saving logs
|
||||
* @property appLogsStore app logs store
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class TangemAppLoggerInitializer(
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val appLogsStore: AppLogsStore,
|
||||
) {
|
||||
|
||||
/** Initialize */
|
||||
|
|
@ -35,7 +35,7 @@ class TangemAppLoggerInitializer(
|
|||
}
|
||||
|
||||
if (PERMITTED_PRIORITY.contains(priority)) {
|
||||
settingsRepository.saveLogMessage(message)
|
||||
appLogsStore.saveLogMessage(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,26 +3,26 @@ package com.tangem.tap.common.log
|
|||
import com.tangem.Log
|
||||
import com.tangem.LogFormat
|
||||
import com.tangem.TangemSdkLogger
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.datasource.local.logs.AppLogsStore
|
||||
|
||||
/**
|
||||
* CardSDK logger implementation
|
||||
*
|
||||
* @property levels logging levels
|
||||
* @property messageFormatter message formatter
|
||||
* @property settingsRepository settings repository
|
||||
* @property levels logging levels
|
||||
* @property messageFormatter message formatter
|
||||
* @property appLogsStore app logs store
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class TangemCardSDKLogger(
|
||||
private val levels: List<Log.Level>,
|
||||
private val messageFormatter: LogFormat,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val appLogsStore: AppLogsStore,
|
||||
) : TangemSdkLogger {
|
||||
|
||||
override fun log(message: () -> String, level: Log.Level) {
|
||||
if (!levels.contains(level)) return
|
||||
|
||||
settingsRepository.saveLogMessage(message = messageFormatter.format(message, level))
|
||||
appLogsStore.saveLogMessage(message = messageFormatter.format(message, level))
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ import timber.log.Timber
|
|||
val logMiddleware: Middleware<AppState> = { _, _ ->
|
||||
{ nextDispatch ->
|
||||
{ action ->
|
||||
Timber.i("Dispatch action: $action")
|
||||
Timber.i("Dispatch action: ${action::class.java.simpleName}")
|
||||
nextDispatch(action)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
package com.tangem.tap.data
|
||||
|
||||
import com.tangem.blockchain.common.logging.BlockchainSDKLogger
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.datasource.local.logs.AppLogsStore
|
||||
|
||||
/**
|
||||
* BlockchainSDK logger implementation
|
||||
*
|
||||
* @property settingsRepository settings repository
|
||||
* @property appLogsStore app logs store
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
internal class TangemBlockchainSDKLogger(
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val appLogsStore: AppLogsStore,
|
||||
) : BlockchainSDKLogger {
|
||||
|
||||
override fun log(level: BlockchainSDKLogger.Level, message: String) {
|
||||
settingsRepository.saveLogMessage(message)
|
||||
appLogsStore.saveLogMessage(message)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import com.tangem.Log
|
|||
import com.tangem.LogFormat
|
||||
import com.tangem.TangemSdkLogger
|
||||
import com.tangem.blockchain.common.logging.BlockchainSDKLogger
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.datasource.local.logs.AppLogsStore
|
||||
import com.tangem.tap.common.log.TangemAppLoggerInitializer
|
||||
import com.tangem.tap.common.log.TangemCardSDKLogger
|
||||
import com.tangem.tap.data.TangemBlockchainSDKLogger
|
||||
|
|
@ -20,13 +20,13 @@ internal object TangemLoggingModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAppLoggerInitializer(settingsRepository: SettingsRepository): TangemAppLoggerInitializer {
|
||||
return TangemAppLoggerInitializer(settingsRepository)
|
||||
fun provideAppLoggerInitializer(appLogsStore: AppLogsStore): TangemAppLoggerInitializer {
|
||||
return TangemAppLoggerInitializer(appLogsStore)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideCardSDKLogger(settingsRepository: SettingsRepository): TangemSdkLogger {
|
||||
fun provideCardSDKLogger(appLogsStore: AppLogsStore): TangemSdkLogger {
|
||||
val logLevels = listOf(
|
||||
Log.Level.ApduCommand,
|
||||
Log.Level.Apdu,
|
||||
|
|
@ -44,13 +44,13 @@ internal object TangemLoggingModule {
|
|||
return TangemCardSDKLogger(
|
||||
levels = logLevels,
|
||||
messageFormatter = LogFormat.StairsFormatter(),
|
||||
settingsRepository = settingsRepository,
|
||||
appLogsStore = appLogsStore,
|
||||
)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideBlockchainSDKLogger(settingsRepository: SettingsRepository): BlockchainSDKLogger {
|
||||
return TangemBlockchainSDKLogger(settingsRepository)
|
||||
fun provideBlockchainSDKLogger(appLogsStore: AppLogsStore): BlockchainSDKLogger {
|
||||
return TangemBlockchainSDKLogger(appLogsStore)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue