aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Merker <merker.stephan@googlemail.com>2012-04-19 22:59:48 +0200
committerSamuel Tardieu <sam@rfc1149.net>2012-04-20 10:12:39 +0200
commit368fef69587fbddbf90ea1dfd00174847e8855c4 (patch)
tree381394a48f37e2871a65087b8be7e4a36f0d9b41
parent65a15ca7c3634dddb5f2863965aabffc69b49541 (diff)
downloadcgeo-368fef69587fbddbf90ea1dfd00174847e8855c4.zip
cgeo-368fef69587fbddbf90ea1dfd00174847e8855c4.tar.gz
cgeo-368fef69587fbddbf90ea1dfd00174847e8855c4.tar.bz2
make Log independent of Settings
- related to #1347: Unit tests fail on Intel image with VM acceleration
-rw-r--r--main/src/cgeo/geocaching/Settings.java10
-rw-r--r--main/src/cgeo/geocaching/utils/Log.java23
2 files changed, 20 insertions, 13 deletions
diff --git a/main/src/cgeo/geocaching/Settings.java b/main/src/cgeo/geocaching/Settings.java
index 872c3f6..8032296 100644
--- a/main/src/cgeo/geocaching/Settings.java
+++ b/main/src/cgeo/geocaching/Settings.java
@@ -6,6 +6,7 @@ import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.MapProviderFactory;
import cgeo.geocaching.maps.interfaces.MapProvider;
import cgeo.geocaching.utils.CryptUtils;
+import cgeo.geocaching.utils.Log;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -116,11 +117,9 @@ public final class Settings {
private static final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(cgeoapplication.getInstance().getBaseContext());
static {
migrateSettings();
+ Log.setDebugUnsaved(sharedPrefs.getBoolean(KEY_DEBUG, false));
}
- // Debug settings are accessed often enough to be cached
- private static Boolean cachedDebug = sharedPrefs.getBoolean(KEY_DEBUG, false);
-
// maps
private static MapProvider mapProvider = null;
@@ -196,7 +195,6 @@ public final class Settings {
e.putInt(KEY_SETTINGS_VERSION, 1) ; // mark migrated
e.commit();
- cachedDebug = sharedPrefs.getBoolean(KEY_DEBUG, false);
}
}
@@ -1082,7 +1080,7 @@ public final class Settings {
public static boolean isDebug() {
- return cachedDebug;
+ return Log.isDebug();
}
public static void setDebug(final boolean debug) {
@@ -1092,7 +1090,7 @@ public final class Settings {
edit.putBoolean(KEY_DEBUG, debug);
}
});
- cachedDebug = debug;
+ Log.setDebugUnsaved(debug);
}
public static boolean getHideLiveMapHint() {
diff --git a/main/src/cgeo/geocaching/utils/Log.java b/main/src/cgeo/geocaching/utils/Log.java
index 6346b87..9f5bd3d 100644
--- a/main/src/cgeo/geocaching/utils/Log.java
+++ b/main/src/cgeo/geocaching/utils/Log.java
@@ -1,43 +1,52 @@
package cgeo.geocaching.utils;
-import cgeo.geocaching.Settings;
final public class Log {
private static final String TAG = "cgeo";
+ private static boolean isDebug = true;
+
+ public static boolean isDebug() {
+ return isDebug;
+ }
+
+ public static void setDebugUnsaved(boolean isDebug) {
+ Log.isDebug = isDebug;
+ }
+
public static void v(final String msg) {
- if (Settings.isDebug()) {
+ if (isDebug) {
android.util.Log.v(TAG, msg);
}
}
public static void v(final String msg, final Throwable t) {
- if (Settings.isDebug()) {
+ if (isDebug) {
android.util.Log.v(TAG, msg, t);
}
}
public static void d(final String msg) {
- if (Settings.isDebug()) {
+ if (isDebug) {
android.util.Log.d(TAG, msg);
}
}
public static void d(final String msg, final Throwable t) {
- if (Settings.isDebug()) {
+ if (isDebug) {
android.util.Log.d(TAG, msg, t);
}
}
public static void i(final String msg) {
- if (Settings.isDebug()) {
+ if (isDebug) {
android.util.Log.i(TAG, msg);
}
}
public static void i(final String msg, final Throwable t) {
- if (Settings.isDebug()) {
+ if (isDebug) {
android.util.Log.i(TAG, msg, t);
}
}