Deafult JNI log level

This commit is contained in:
M66B
2023-12-30 17:14:02 +01:00
parent 09479f8eb0
commit 6492a7a592
5 changed files with 42 additions and 29 deletions

View File

@@ -123,6 +123,8 @@ public class Log {
System.loadLibrary("fairemail");
}
public static native void jni_set_log_level(int level);
public static native long[] jni_safe_runtime_stats();
public static int d(String msg) {
@@ -338,9 +340,20 @@ public class Log {
static void setup(Context context) {
ctx = context;
setLevel(context);
setupBugsnag(context);
}
static void setLevel(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int level = prefs.getInt("log_level", getDefaultLogLevel());
jni_set_log_level(level);
}
static int getDefaultLogLevel() {
return (BuildConfig.DEBUG || BuildConfig.TEST_RELEASE ? android.util.Log.INFO : android.util.Log.WARN);
}
private static void setupBugsnag(final Context context) {
try {
Log.i("Configuring Bugsnag");