mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-01 22:56:33 +02:00
Added log level debug option
This commit is contained in:
@@ -123,28 +123,52 @@ import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
import io.requery.android.database.CursorWindowAllocationException;
|
||||
|
||||
public class Log {
|
||||
private static boolean debug = false;
|
||||
private static int level = android.util.Log.INFO;
|
||||
private static final int MAX_CRASH_REPORTS = 5;
|
||||
private static final String TAG = "fairemail";
|
||||
|
||||
public static void setDebug(boolean value) {
|
||||
debug = value;
|
||||
public static void setLevel(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean debug = prefs.getBoolean("debug", false);
|
||||
if (debug)
|
||||
level = android.util.Log.DEBUG;
|
||||
else
|
||||
level = prefs.getInt("log_level", getDefaultLogLevel());
|
||||
android.util.Log.d(TAG, "Log level=" + level);
|
||||
}
|
||||
|
||||
public static int getDefaultLogLevel() {
|
||||
return (BuildConfig.DEBUG ? android.util.Log.INFO : android.util.Log.WARN);
|
||||
}
|
||||
|
||||
public static int d(String msg) {
|
||||
if (debug)
|
||||
if (level <= android.util.Log.DEBUG)
|
||||
return android.util.Log.d(TAG, msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int d(String tag, String msg) {
|
||||
if (level <= android.util.Log.DEBUG)
|
||||
return android.util.Log.d(tag, msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int i(String msg) {
|
||||
if (BuildConfig.BETA_RELEASE)
|
||||
if (level <= android.util.Log.INFO)
|
||||
return android.util.Log.i(TAG, msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int i(String tag, String msg) {
|
||||
if (level <= android.util.Log.INFO)
|
||||
return android.util.Log.i(tag, msg);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int w(String msg) {
|
||||
return android.util.Log.w(TAG, msg);
|
||||
}
|
||||
@@ -262,9 +286,7 @@ public class Log {
|
||||
}
|
||||
|
||||
static void setup(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
debug = prefs.getBoolean("debug", false);
|
||||
|
||||
setLevel(context);
|
||||
setupBugsnag(context);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user