diff options
| -rw-r--r-- | main/src/cgeo/geocaching/Settings.java | 10 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/utils/Log.java | 23 |
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); } } |
