Skip to content

Commit f7401b7

Browse files
Changed: Set DEFAULT_LOG_TAG at application startup as per termux/termux-app@1b794b35 and termux/termux-app@6ff55729
Also set log level when `TermuxTaskerMainActivity` is resumed and don't commit to file if not needed.
1 parent 35a6ea0 commit f7401b7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

app/src/main/java/com/termux/tasker/TermuxTaskerApplication.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.app.Application;
44
import android.content.Context;
5+
import android.util.Log;
56

67
import com.termux.shared.logger.Logger;
78
import com.termux.shared.termux.TermuxConstants;
@@ -10,22 +11,24 @@
1011

1112
public class TermuxTaskerApplication extends Application {
1213

14+
public static final String LOG_TAG = "TermuxTaskerApplication";
15+
1316
public void onCreate() {
1417
super.onCreate();
1518

19+
Log.i(LOG_TAG, "AppInit");
20+
1621
Context context = getApplicationContext();
1722

1823
// Set crash handler for the app
19-
TermuxCrashUtils.setCrashHandler(this);
24+
TermuxCrashUtils.setCrashHandler(context);
2025

2126
// Set log config for the app
2227
setLogConfig(context, true);
23-
24-
Logger.logDebug("Starting Application");
2528
}
2629

2730
public static void setLogConfig(Context context, boolean commitToFile) {
28-
Logger.setDefaultLogTag(TermuxConstants.TERMUX_TASKER_APP_NAME.replaceAll(":", ""));
31+
Logger.setDefaultLogTag(TermuxConstants.TERMUX_TASKER_APP_NAME.replaceAll("[: ]", ""));
2932

3033
// Load the log level from shared preferences and set it to the Logger.CURRENT_LOG_LEVEL
3134
TermuxTaskerAppSharedPreferences preferences = TermuxTaskerAppSharedPreferences.build(context);

app/src/main/java/com/termux/tasker/activities/TermuxTaskerMainActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.termux.shared.termux.theme.TermuxThemeUtils;
1515
import com.termux.shared.theme.NightMode;
1616
import com.termux.tasker.R;
17+
import com.termux.tasker.TermuxTaskerApplication;
1718

1819
public class TermuxTaskerMainActivity extends AppCompatActivity {
1920

@@ -40,6 +41,9 @@ protected void onCreate(Bundle savedInstanceState) {
4041
protected void onResume() {
4142
super.onResume();
4243

44+
// Set log level for the app
45+
TermuxTaskerApplication.setLogConfig(this, false);
46+
4347
Logger.logVerbose(LOG_TAG, "onResume");
4448

4549
setChangeLauncherActivityStateViews();

0 commit comments

Comments
 (0)