mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
feat: setup Beagle for debugging
This commit is contained in:
parent
816aca5ba1
commit
2762c17578
@ -102,7 +102,13 @@ dependencies {
|
||||
|
||||
if (snapshot.snapshot) {
|
||||
implementation(libs.thirdparty.whatthestack)
|
||||
implementation(libs.thirdparty.beagle.ui.drawer)
|
||||
implementation(libs.thirdparty.beagle.log)
|
||||
} else {
|
||||
debugImplementation(libs.thirdparty.beagle.ui.drawer)
|
||||
debugImplementation(libs.thirdparty.beagle.log)
|
||||
releaseImplementation(libs.thirdparty.beagle.noop)
|
||||
releaseImplementation(libs.thirdparty.beagle.log.noop)
|
||||
debugImplementation(libs.thirdparty.whatthestack)
|
||||
}
|
||||
|
||||
|
@ -18,17 +18,28 @@ import app.passwordstore.util.extensions.getString
|
||||
import app.passwordstore.util.features.Feature
|
||||
import app.passwordstore.util.features.Features
|
||||
import app.passwordstore.util.git.sshj.setUpBouncyCastleForSshj
|
||||
import app.passwordstore.util.log.ForwardingLogcatLogger
|
||||
import app.passwordstore.util.proxy.ProxyUtils
|
||||
import app.passwordstore.util.settings.GitSettings
|
||||
import app.passwordstore.util.settings.PreferenceKeys
|
||||
import app.passwordstore.util.settings.runMigrations
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import com.pandulapeter.beagle.Beagle
|
||||
import com.pandulapeter.beagle.common.configuration.Behavior
|
||||
import com.pandulapeter.beagle.log.BeagleLogger
|
||||
import com.pandulapeter.beagle.modules.AppInfoButtonModule
|
||||
import com.pandulapeter.beagle.modules.DeviceInfoModule
|
||||
import com.pandulapeter.beagle.modules.DividerModule
|
||||
import com.pandulapeter.beagle.modules.HeaderModule
|
||||
import com.pandulapeter.beagle.modules.LifecycleLogListModule
|
||||
import com.pandulapeter.beagle.modules.LogListModule
|
||||
import com.pandulapeter.beagle.modules.PaddingModule
|
||||
import com.pandulapeter.beagle.modules.ScreenCaptureToolboxModule
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import io.sentry.Sentry
|
||||
import io.sentry.protocol.User
|
||||
import java.util.concurrent.Executors
|
||||
import javax.inject.Inject
|
||||
import logcat.AndroidLogcatLogger
|
||||
import logcat.LogPriority.DEBUG
|
||||
import logcat.LogPriority.VERBOSE
|
||||
import logcat.LogcatLogger
|
||||
@ -51,7 +62,33 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
|
||||
BuildConfig.ENABLE_DEBUG_FEATURES ||
|
||||
prefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false)
|
||||
) {
|
||||
LogcatLogger.install(AndroidLogcatLogger(DEBUG))
|
||||
Beagle.initialize(
|
||||
application = this,
|
||||
behavior =
|
||||
Behavior(
|
||||
logBehavior =
|
||||
Behavior.LogBehavior(
|
||||
loggers = listOf(BeagleLogger),
|
||||
)
|
||||
)
|
||||
)
|
||||
Beagle.set(
|
||||
HeaderModule(
|
||||
title = getString(R.string.app_name),
|
||||
subtitle = BuildConfig.APPLICATION_ID,
|
||||
text =
|
||||
"${BuildConfig.BUILD_TYPE} v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
|
||||
),
|
||||
AppInfoButtonModule(),
|
||||
PaddingModule(),
|
||||
ScreenCaptureToolboxModule(),
|
||||
DividerModule(),
|
||||
LogListModule(),
|
||||
LifecycleLogListModule(),
|
||||
DividerModule(),
|
||||
DeviceInfoModule(),
|
||||
)
|
||||
LogcatLogger.install(ForwardingLogcatLogger(DEBUG))
|
||||
setVmPolicy()
|
||||
}
|
||||
prefs.registerOnSharedPreferenceChangeListener(this)
|
||||
|
@ -0,0 +1,24 @@
|
||||
package app.passwordstore.util.log
|
||||
|
||||
import com.pandulapeter.beagle.log.BeagleLogger
|
||||
import logcat.AndroidLogcatLogger
|
||||
import logcat.LogPriority
|
||||
import logcat.LogPriority.DEBUG
|
||||
import logcat.LogcatLogger
|
||||
|
||||
/**
|
||||
* Wrapper around [AndroidLogcatLogger] that ensures all logged messages are also forwarded to
|
||||
* [BeagleLogger].
|
||||
*/
|
||||
class ForwardingLogcatLogger(minPriority: LogPriority = DEBUG) : LogcatLogger {
|
||||
private val androidLogger = AndroidLogcatLogger(minPriority)
|
||||
|
||||
override fun isLoggable(priority: LogPriority): Boolean {
|
||||
return androidLogger.isLoggable(priority)
|
||||
}
|
||||
|
||||
override fun log(priority: LogPriority, tag: String, message: String) {
|
||||
androidLogger.log(priority, tag, message)
|
||||
BeagleLogger.log(message = "[$tag]: $message", label = "Logcat", isPersisted = true)
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
[versions]
|
||||
agp = "7.3.1"
|
||||
androidxActivity = "1.7.0-alpha01"
|
||||
beagle = "2.9.0"
|
||||
bouncycastle = "1.72"
|
||||
composeFoundation = "1.3.0-rc01"
|
||||
composeUi = "1.3.0-rc01"
|
||||
@ -74,6 +75,10 @@ testing-robolectric = "org.robolectric:robolectric:4.9"
|
||||
testing-sharedPrefsMock = "com.github.android-password-store:shared-preferences-fake:2.0.0"
|
||||
testing-testparameterinjector = "com.google.testparameterinjector:test-parameter-injector:1.9"
|
||||
testing-turbine = "app.cash.turbine:turbine:0.12.0"
|
||||
thirdparty-beagle-log = { module = "io.github.pandulapeter.beagle:log", version.ref = "beagle" }
|
||||
thirdparty-beagle-log-noop = { module = "io.github.pandulapeter.beagle:log-noop", version.ref = "beagle" }
|
||||
thirdparty-beagle-noop = { module = "io.github.pandulapeter.beagle:noop", version.ref = "beagle" }
|
||||
thirdparty-beagle-ui-drawer = { module = "io.github.pandulapeter.beagle:ui-drawer", version.ref = "beagle" }
|
||||
thirdparty-bouncycastle-bcpkix = { module = "org.bouncycastle:bcpkix-jdk15to18", version.ref = "bouncycastle" }
|
||||
thirdparty-bouncycastle-bcprov = { module = "org.bouncycastle:bcprov-jdk15to18", version.ref = "bouncycastle" }
|
||||
thirdparty-commons_codec = "commons-codec:commons-codec:1.14"
|
||||
|
Loading…
x
Reference in New Issue
Block a user