Changed!: Remove TermuxConstants reference from Logger and set DEFAULT_LOG_TAG at application startup

Plugin apps must do the same
This commit is contained in:
agnostic-apollo
2021-10-26 08:00:45 +05:00
parent 8e506859a6
commit 6ff5572999
3 changed files with 28 additions and 8 deletions

View File

@@ -1,7 +1,9 @@
package com.termux.app;
import android.app.Application;
import android.content.Context;
import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.termux.crash.TermuxCrashUtils;
import com.termux.shared.termux.settings.preferences.TermuxAppSharedPreferences;
import com.termux.shared.logger.Logger;
@@ -14,16 +16,19 @@ public class TermuxApplication extends Application {
// Set crash handler for the app
TermuxCrashUtils.setCrashHandler(this);
// Set log level for the app
setLogLevel();
// Set log config for the app
setLogConfig(getApplicationContext());
Logger.logDebug("Starting Application");
}
private void setLogLevel() {
public static void setLogConfig(Context context) {
Logger.setDefaultLogTag(TermuxConstants.TERMUX_APP_NAME);
// Load the log level from shared preferences and set it to the {@link Logger.CURRENT_LOG_LEVEL}
TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences.build(getApplicationContext());
TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences.build(context);
if (preferences == null) return;
preferences.setLogLevel(null, preferences.getLogLevel());
Logger.logDebug("Starting Application");
}
}