Simon Schubert
08/12/2019, 4:14 PMobject L {
private const val TAG = "FOOBAR"
fun e(log: String) {
if (BuildConfig.DEBUG) {
Log.e(TAG, log)
}
}
...
}
henrikhorbovyi
08/12/2019, 4:15 PMThomas
08/12/2019, 4:25 PMobject L {
const val TAG = "FOOBAR"
inline fun e(log: () -> String) {
if (BuildConfig.DEBUG) {
Log.e(TAG, log())
}
}
...
}
L.e { "message to log" }
Simon Schubert
08/12/2019, 4:35 PMhenrikhorbovyi
08/12/2019, 4:41 PMThomas
08/12/2019, 4:41 PMif
statement. The compiled code will look like this:
if (false) {
Log.e(TAG, "message to log")
}
That way all the code is removed.henrikhorbovyi
08/12/2019, 4:41 PMThomas
08/12/2019, 4:42 PMProGuard remove itMaybe it removes the logs but it does NOT remove the string concatenation that is needed for the message. So if someone decompiles your APK the log messages are still there
henrikhorbovyi
08/12/2019, 4:58 PMSimon Schubert
08/12/2019, 5:23 PMandym
08/12/2019, 9:55 PMhenrikhorbovyi
08/12/2019, 10:25 PMflorent
08/13/2019, 10:26 AMThomas
08/13/2019, 10:43 AMflorent
08/13/2019, 11:13 AMThomas
08/13/2019, 11:17 AMif (false) { ... }
statement so it will be removed completely when compiling a release build. That's the point of using this method instead of the original one that was posted.florent
08/13/2019, 11:22 AMThomas
08/13/2019, 11:26 AM