Simplify debugging logging via Utils

This commit is contained in:
Daniel Martí 2015-08-20 18:37:25 -07:00
parent 4c75f6078d
commit 96014a7365
5 changed files with 22 additions and 22 deletions

View File

@ -47,7 +47,7 @@ public class CompatibilityChecker extends Compatibility {
for (FeatureInfo fi : pm.getSystemAvailableFeatures()) {
logMsg.append('\n').append(fi.name);
}
Log.d(TAG, logMsg.toString());
Utils.DebugLog(TAG, logMsg.toString());
}
for (FeatureInfo fi : pm.getSystemAvailableFeatures()) {
features.add(fi.name);
@ -102,10 +102,8 @@ public class CompatibilityChecker extends Compatibility {
}
if (!features.contains(feat)) {
Collections.addAll(incompatibleReasons, feat.split(","));
if (BuildConfig.DEBUG) {
Log.d(TAG, apk.id + " vercode " + apk.vercode
+ " is incompatible based on lack of " + feat);
}
Utils.DebugLog(TAG, apk.id + " vercode " + apk.vercode
+ " is incompatible based on lack of " + feat);
}
}
}
@ -113,11 +111,9 @@ public class CompatibilityChecker extends Compatibility {
for (final String code : apk.nativecode) {
incompatibleReasons.add(code);
}
if (BuildConfig.DEBUG) {
Log.d(TAG, apk.id + " vercode " + apk.vercode
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
+ " while your architectures are " + cpuAbisDesc);
}
Utils.DebugLog(TAG, apk.id + " vercode " + apk.vercode
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
+ " while your architectures are " + cpuAbisDesc);
}
return incompatibleReasons;

View File

@ -258,9 +258,7 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Invalidating preference '" + key + "'.");
}
Utils.DebugLog(TAG, "Invalidating preference '" + key + "'.");
uninitialize(key);
switch (key) {

View File

@ -633,4 +633,16 @@ public final class Utils {
}
}
public static void DebugLog(String tag, String msg) {
if (BuildConfig.DEBUG) {
Log.d(tag, msg);
}
}
public static void DebugLog(String tag, String msg, Throwable tr) {
if (BuildConfig.DEBUG) {
Log.d(tag, msg, tr);
}
}
}

View File

@ -59,9 +59,7 @@ public class FileCompat extends Compatibility {
dest.getAbsolutePath()
};
try {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Executing command: " + commands[0] + " " + commands[1] + " " + commands[2]);
}
Utils.DebugLog(TAG, "Executing command: " + commands[0] + " " + commands[1] + " " + commands[2]);
Process proc = Runtime.getRuntime().exec(commands);
Utils.consumeStream(proc.getInputStream());
Utils.consumeStream(proc.getErrorStream());
@ -109,9 +107,7 @@ public class FileCompat extends Compatibility {
};
try {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Executing following command: " + args[0] + " " + args[1] + " " + args[2]);
}
Utils.DebugLog(TAG, "Executing following command: " + args[0] + " " + args[1] + " " + args[2]);
Process proc = Runtime.getRuntime().exec(args);
Utils.consumeStream(proc.getInputStream());
Utils.consumeStream(proc.getErrorStream());

View File

@ -85,9 +85,7 @@ public class WifiStateChangeService extends Service {
FDroidApp.ipAddressString = getIpAddressFromNetworkInterface();
}
Thread.sleep(1000);
if (BuildConfig.DEBUG) {
Log.d(TAG, "waiting for an IP address...");
}
Utils.DebugLog(TAG, "waiting for an IP address...");
}
if (isCancelled()) // can be canceled by a change via WifiStateChangeReceiver
return null;