Skip to content

Commit

Permalink
[#1435] Eliminate logging with Proguard
Browse files Browse the repository at this point in the history
- Closes #1435
- Changelog update
  • Loading branch information
HonzaR committed Apr 17, 2024
1 parent 2c09776 commit 652487e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed
- The SDK components no longer contain logging statements in the release build
- Gradle 8.7
- Android Gradle Plugin 8.3.0
- Kotlin 1.9.23
Expand Down
9 changes: 9 additions & 0 deletions sdk-lib/proguard-consumer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Strip out log messages
-assumenosideeffects public class cash.z.ecc.android.sdk.internal.Twig {
public static *** verbose(...);
public static *** debug(...);
public static *** info(...);
public static *** warn(...);
public static *** error(...);
public static *** assertLoggingStripped();
}
9 changes: 9 additions & 0 deletions sdk-lib/src/main/java/cash/z/ecc/android/sdk/Synchronizer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ interface Synchronizer {

validateAlias(alias)

validateLogging()

val saplingParamTool = SaplingParamTool.new(applicationContext)

val loadedCheckpoint =
Expand Down Expand Up @@ -739,3 +741,10 @@ private fun validateAlias(alias: String) {
"characters and only contain letters, digits, hyphens, and underscores."
}
}

private fun validateLogging() {
if (!BuildConfig.DEBUG) {
// In release builds, logs should be stripped by R8 rules
Twig.assertLoggingStripped()
}
}

0 comments on commit 652487e

Please sign in to comment.