mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-28 01:49:23 +01:00
API: return String instead of printing out to logcat.
This commit is contained in:
parent
ec3512fd5b
commit
4ffab7fc13
@ -28,7 +28,7 @@ interface DebugService {
|
||||
fun getAllRealmConfigurations(): List<RealmConfiguration>
|
||||
|
||||
/**
|
||||
* Prints out info on DB size to logcat.
|
||||
* Get info on DB size.
|
||||
*/
|
||||
fun logDbUsageInfo()
|
||||
fun getDbUsageInfo(): String
|
||||
}
|
||||
|
@ -323,9 +323,9 @@ interface Session {
|
||||
fun getUiaSsoFallbackUrl(authenticationSessionId: String): String
|
||||
|
||||
/**
|
||||
* Debug API, will print out info on DB size to logcat.
|
||||
* Debug API, will return info about the DB.
|
||||
*/
|
||||
fun logDbUsageInfo()
|
||||
fun getDbUsageInfo(): String
|
||||
|
||||
/**
|
||||
* Debug API, return the list of all RealmConfiguration used by this session.
|
||||
|
@ -19,16 +19,15 @@ package org.matrix.android.sdk.internal.database.tools
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import org.matrix.android.sdk.BuildConfig
|
||||
import timber.log.Timber
|
||||
|
||||
internal class RealmDebugTools(
|
||||
private val realmConfiguration: RealmConfiguration
|
||||
) {
|
||||
/**
|
||||
* Log info about the DB.
|
||||
* Get info about the DB.
|
||||
*/
|
||||
fun logInfo(baseName: String) {
|
||||
buildString {
|
||||
fun getInfo(baseName: String): String {
|
||||
return buildString {
|
||||
append("\n$baseName Realm located at : ${realmConfiguration.realmDirectory}/${realmConfiguration.realmFileName}")
|
||||
|
||||
if (BuildConfig.LOG_PRIVATE_DATA) {
|
||||
@ -54,7 +53,6 @@ internal class RealmDebugTools(
|
||||
separator()
|
||||
}
|
||||
}
|
||||
.let { Timber.i(it) }
|
||||
}
|
||||
|
||||
private fun StringBuilder.separator() = append("\n==============================================")
|
||||
|
@ -36,9 +36,9 @@ internal class DefaultDebugService @Inject constructor(
|
||||
realmConfigurationGlobal
|
||||
}
|
||||
|
||||
override fun logDbUsageInfo() {
|
||||
RealmDebugTools(realmConfigurationAuth).logInfo("Auth")
|
||||
RealmDebugTools(realmConfigurationGlobal).logInfo("Global")
|
||||
sessionManager.getLastSession()?.logDbUsageInfo()
|
||||
override fun getDbUsageInfo() = buildString {
|
||||
append(RealmDebugTools(realmConfigurationAuth).getInfo("Auth"))
|
||||
append(RealmDebugTools(realmConfigurationGlobal).getInfo("Global"))
|
||||
append(sessionManager.getLastSession()?.getDbUsageInfo())
|
||||
}
|
||||
}
|
||||
|
@ -263,11 +263,11 @@ internal class DefaultSession @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun logDbUsageInfo() {
|
||||
RealmDebugTools(realmConfiguration).logInfo("Session")
|
||||
RealmDebugTools(realmConfigurationCrypto).logInfo("Crypto")
|
||||
RealmDebugTools(realmConfigurationIdentity).logInfo("Identity")
|
||||
RealmDebugTools(realmConfigurationContentScanner).logInfo("ContentScanner")
|
||||
override fun getDbUsageInfo() = buildString {
|
||||
append(RealmDebugTools(realmConfiguration).getInfo("Session"))
|
||||
append(RealmDebugTools(realmConfigurationCrypto).getInfo("Crypto"))
|
||||
append(RealmDebugTools(realmConfigurationIdentity).getInfo("Identity"))
|
||||
append(RealmDebugTools(realmConfigurationContentScanner).getInfo("ContentScanner"))
|
||||
}
|
||||
|
||||
override fun getRealmConfigurations(): List<RealmConfiguration> {
|
||||
|
@ -499,10 +499,15 @@ class BugReporter @Inject constructor(
|
||||
*/
|
||||
fun openBugReportScreen(activity: FragmentActivity, reportType: ReportType = ReportType.BUG_REPORT) {
|
||||
screenshot = takeScreenshot(activity)
|
||||
matrix.debugService().logDbUsageInfo()
|
||||
logDbInfo()
|
||||
activity.startActivity(BugReportActivity.intent(activity, reportType))
|
||||
}
|
||||
|
||||
private fun logDbInfo() {
|
||||
val dbInfo = matrix.debugService().getDbUsageInfo()
|
||||
Timber.i(dbInfo)
|
||||
}
|
||||
|
||||
private fun rageShakeAppNameForReport(reportType: ReportType): String {
|
||||
// As per https://github.com/matrix-org/rageshake
|
||||
// app: Identifier for the application (eg 'riot-web').
|
||||
|
Loading…
x
Reference in New Issue
Block a user