Toggle logcat on/off

This commit is contained in:
jens 2025-04-27 13:32:30 +02:00
parent b6d7958389
commit f04c517c80
5 changed files with 26 additions and 9 deletions

View File

@ -314,15 +314,18 @@ public class Miscellaneous extends Service
header = "Automation"; header = "Automation";
} }
if(type.equals("e")) if(Settings.logToConsole)
Log.e(header, description); {
if (type.equals("e"))
Log.e(header, description);
if (type.equals("w"))
Log.w(header, description);
if (type.equals("i"))
Log.i(header, description);
}
if(type.equals("w"))
Log.w(header, description);
if(type.equals("i"))
Log.i(header, description);
if(Settings.writeLogFile && Settings.logLevel >= logLevel) if(Settings.writeLogFile && Settings.logLevel >= logLevel)
{ {
writeToLogFile(type, header, description); writeToLogFile(type, header, description);

View File

@ -30,6 +30,7 @@ public class Settings implements SharedPreferences
public static int gpsTimeout; public static int gpsTimeout;
public static long minimumTimeBetweenUpdate; public static long minimumTimeBetweenUpdate;
public static boolean startServiceAtSystemBoot; public static boolean startServiceAtSystemBoot;
public static boolean logToConsole;
public static boolean writeLogFile; public static boolean writeLogFile;
public static long logLevel; public static long logLevel;
public static int logFileMaxSize; public static int logFileMaxSize;
@ -98,6 +99,7 @@ public class Settings implements SharedPreferences
public static final int default_gpsTimeout = 300; // seconds public static final int default_gpsTimeout = 300; // seconds
public static final long default_minimumTimeBetweenUpdate = 30000; // in Milliseconds public static final long default_minimumTimeBetweenUpdate = 30000; // in Milliseconds
public static final boolean default_startServiceAtSystemBoot = false; public static final boolean default_startServiceAtSystemBoot = false;
public static final boolean default_logToConsole = false;
public static final boolean default_writeLogFile = false; public static final boolean default_writeLogFile = false;
public static final long default_logLevel = 2; public static final long default_logLevel = 2;
public static final int default_logFileMaxSize = 10; public static final int default_logFileMaxSize = 10;
@ -199,6 +201,7 @@ public class Settings implements SharedPreferences
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
startServiceAtSystemBoot = prefs.getBoolean("startServiceAtSystemBoot", default_startServiceAtSystemBoot); startServiceAtSystemBoot = prefs.getBoolean("startServiceAtSystemBoot", default_startServiceAtSystemBoot);
logToConsole = prefs.getBoolean("logToConsole", default_logToConsole);
writeLogFile = prefs.getBoolean("writeLogFile", default_writeLogFile); writeLogFile = prefs.getBoolean("writeLogFile", default_writeLogFile);
boolean useTextToSpeech = false; boolean useTextToSpeech = false;
@ -339,6 +342,9 @@ public class Settings implements SharedPreferences
if(!prefs.contains("startServiceAtSystemBoot") || force) if(!prefs.contains("startServiceAtSystemBoot") || force)
editor.putBoolean("startServiceAtSystemBoot", default_startServiceAtSystemBoot); editor.putBoolean("startServiceAtSystemBoot", default_startServiceAtSystemBoot);
if(!prefs.contains("logToConsole") || force)
editor.putBoolean("logToConsole", default_logToConsole);
if(!prefs.contains("writeLogFile") || force) if(!prefs.contains("writeLogFile") || force)
editor.putBoolean("writeLogFile", default_writeLogFile); editor.putBoolean("writeLogFile", default_writeLogFile);
@ -515,6 +521,7 @@ public class Settings implements SharedPreferences
Editor editor = prefs.edit(); Editor editor = prefs.edit();
editor.putBoolean("startServiceAtSystemBoot", startServiceAtSystemBoot); editor.putBoolean("startServiceAtSystemBoot", startServiceAtSystemBoot);
editor.putBoolean("logToConsole", logToConsole);
editor.putBoolean("writeLogFile", writeLogFile); editor.putBoolean("writeLogFile", writeLogFile);
// editor.putBoolean("useTextToSpeech", useTextToSpeech); // editor.putBoolean("useTextToSpeech", useTextToSpeech);
editor.putBoolean("useTextToSpeechOnNormal", useTextToSpeechOnNormal); editor.putBoolean("useTextToSpeechOnNormal", useTextToSpeechOnNormal);

View File

@ -28,6 +28,11 @@
android:summary="@string/showIconWhenServiceIsRunning" android:summary="@string/showIconWhenServiceIsRunning"
android:title="@string/showIcon" /> android:title="@string/showIcon" />
<CheckBoxPreference
android:key="logToConsole"
android:summary="@string/onOff"
android:title="@string/logToConsole" />
<CheckBoxPreference <CheckBoxPreference
android:key="writeLogFile" android:key="writeLogFile"
android:summary="@string/onOff" android:summary="@string/onOff"

View File

@ -951,4 +951,5 @@
<string name="importChooseFolderNotice">In the following dialog do not try to select specific files, but choose the folder in which the Automation backup files reside. If the choose button is disabled, you have found an Android limitation. In that case try moving the files to a subdirectory first.</string> <string name="importChooseFolderNotice">In the following dialog do not try to select specific files, but choose the folder in which the Automation backup files reside. If the choose button is disabled, you have found an Android limitation. In that case try moving the files to a subdirectory first.</string>
<string name="matches">matches</string> <string name="matches">matches</string>
<string name="doesNotMatch">does not match</string> <string name="doesNotMatch">does not match</string>
<string name="logToConsole">Log to console (logcat)</string>
</resources> </resources>

View File

@ -1,2 +1,3 @@
* Fixed: Crash when triggering a URL without parameter pairs * Fixed: Crash when triggering a URL without parameter pairs
* Fixed: When checking for battery charging type "any" the trigger didn't fire. * Fixed: When checking for battery charging type "any" the trigger didn't fire.
* Added: Settings to turn on/off console logging (logcat)