disable logging for tagged release builds

This commit is contained in:
Eric House 2019-01-09 19:41:33 -08:00
parent 1625ec9062
commit bdbd5bc1ee
2 changed files with 28 additions and 10 deletions

View file

@ -16,6 +16,10 @@ if (! forFDroid) {
}
GITREV = GITREV.execute().text.trim()
// Make CURTAG non-empty IFF we're at a tag (release build)
def CURTAG = "git describe --exact-match".execute().text.trim()
// print "CURTAG: " + CURTAG + "\n"
apply plugin: 'com.android.application'
@ -63,6 +67,7 @@ android {
productFlavors {
all {
buildConfigField "String", "BUILD_INFO_NAME", "\"${BUILD_INFO_NAME}\""
buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true"
resValue "string", "invite_prefix", "/and/"
}

View file

@ -24,27 +24,40 @@ import java.util.Formatter;
public class Log {
private static final String PRE_TAG = BuildConfig.FLAVOR + "-";
private static final boolean LOGGING_ENABLED
= BuildConfig.DEBUG || !BuildConfig.IS_TAGGED_BUILD;
private static final boolean ERROR_LOGGING_ENABLED = true;
public static void d( String tag, String fmt, Object... args ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.d( PRE_TAG + tag, str );
if ( LOGGING_ENABLED ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.d( PRE_TAG + tag, str );
}
}
public static void w( String tag, String fmt, Object... args ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.w( PRE_TAG + tag, str );
if ( LOGGING_ENABLED ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.w( PRE_TAG + tag, str );
}
}
public static void e( String tag, String fmt, Object... args ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.e( PRE_TAG + tag, str );
if ( ERROR_LOGGING_ENABLED ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.e( PRE_TAG + tag, str );
}
}
public static void i( String tag, String fmt, Object... args ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.i( PRE_TAG + tag, str );
if ( LOGGING_ENABLED ) {
String str = new Formatter().format( fmt, args ).toString();
android.util.Log.i( PRE_TAG + tag, str );
}
}
public static void ex( String tag, Exception exception )
{
w( tag, "Exception: %s", exception.toString() );
DbgUtils.printStack( tag, exception.getStackTrace() );
if ( LOGGING_ENABLED ) {
w( tag, "Exception: %s", exception.toString() );
DbgUtils.printStack( tag, exception.getStackTrace() );
}
}
}