From d147728acda463bd425b5f4781b3fbd8394c5b37 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 14 Mar 2019 21:25:47 +0000 Subject: [PATCH] Add a setting to control log verbosity. --- app/src/main/java/com/etesync/syncadapter/log/Logger.kt | 5 +++-- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/settings_app.xml | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/log/Logger.kt b/app/src/main/java/com/etesync/syncadapter/log/Logger.kt index 6a29bb81..e04bf7f7 100644 --- a/app/src/main/java/com/etesync/syncadapter/log/Logger.kt +++ b/app/src/main/java/com/etesync/syncadapter/log/Logger.kt @@ -34,6 +34,7 @@ import java.util.logging.Level object Logger : SharedPreferences.OnSharedPreferenceChangeListener { private const val LOG_TO_FILE = "log_to_file" + private const val LOG_VERBOSE = "log_verbose" val log = java.util.logging.Logger.getLogger("etesync")!! @@ -49,7 +50,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener { } override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { - if (key == LOG_TO_FILE) { + if (key == LOG_TO_FILE || key == LOG_VERBOSE) { log.info("Logging settings changed; re-initializing logger") reinitialize() } @@ -57,7 +58,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener { private fun reinitialize() { val logToFile = preferences.getBoolean(LOG_TO_FILE, false) - val logVerbose = logToFile || Log.isLoggable(Logger.log.name, Log.DEBUG) + val logVerbose = preferences.getBoolean(LOG_VERBOSE, false) || Log.isLoggable(Logger.log.name, Log.DEBUG) log.info("Verbose logging: $logVerbose; to file: $logToFile") diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7fcfcf67..e4fd18a8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -106,6 +106,8 @@ Log to external file Logging to external storage. Disable to hide the notification. External file logging is disabled + Verbose logging + Verbose logs may contain private information Show debug info View/share software and configuration details Force Language diff --git a/app/src/main/res/xml/settings_app.xml b/app/src/main/res/xml/settings_app.xml index 1baba44d..91b50f80 100644 --- a/app/src/main/res/xml/settings_app.xml +++ b/app/src/main/res/xml/settings_app.xml @@ -67,6 +67,11 @@ android:summaryOn="@string/app_settings_log_to_external_storage_on" android:summaryOff="@string/app_settings_log_to_external_storage_off"/> + +