Rename debug logging property
This commit is contained in:
parent
113f51df94
commit
dd5e12e779
12 changed files with 39 additions and 53 deletions
|
@ -18,26 +18,11 @@ object K9 : KoinComponent {
|
|||
|
||||
|
||||
/**
|
||||
* If this is enabled, various development settings will be enabled
|
||||
* It should NEVER be on for Market builds
|
||||
* Right now, it just governs strictmode
|
||||
* If this is `true`, various development settings will be enabled.
|
||||
*/
|
||||
@JvmField
|
||||
val DEVELOPER_MODE = BuildConfig.DEBUG
|
||||
|
||||
/**
|
||||
* If this is enabled there will be additional logging information sent to Log.d, including protocol dumps.
|
||||
* Controlled by Preferences at run-time
|
||||
*/
|
||||
private var DEBUG = false
|
||||
|
||||
/**
|
||||
* If this is enabled than logging that normally hides sensitive information like passwords will show that
|
||||
* information.
|
||||
*/
|
||||
@JvmField
|
||||
var DEBUG_SENSITIVE = false
|
||||
|
||||
|
||||
private const val VERSION_MIGRATE_OPENPGP_TO_ACCOUNTS = 63
|
||||
|
||||
|
@ -149,6 +134,16 @@ object K9 : KoinComponent {
|
|||
}
|
||||
|
||||
|
||||
@JvmStatic
|
||||
var isDebugLoggingEnabled: Boolean = DEVELOPER_MODE
|
||||
set(debug) {
|
||||
field = debug
|
||||
updateLoggingStatus()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
var isSensitiveDebugLoggingEnabled: Boolean = false
|
||||
|
||||
@JvmStatic
|
||||
var k9Language = ""
|
||||
|
||||
|
@ -344,14 +339,6 @@ object K9 : KoinComponent {
|
|||
return quietTimeChecker.isQuietTime
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
var isDebug: Boolean
|
||||
get() = DEBUG
|
||||
set(debug) {
|
||||
DEBUG = debug
|
||||
updateLoggingStatus()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@JvmStatic
|
||||
fun isSortAscending(sortType: SortType): Boolean {
|
||||
|
@ -370,9 +357,9 @@ object K9 : KoinComponent {
|
|||
|
||||
fun init(context: Context) {
|
||||
K9MailLib.setDebugStatus(object : K9MailLib.DebugStatus {
|
||||
override fun enabled(): Boolean = DEBUG
|
||||
override fun enabled(): Boolean = isDebugLoggingEnabled
|
||||
|
||||
override fun debugSensitive(): Boolean = DEBUG_SENSITIVE
|
||||
override fun debugSensitive(): Boolean = isSensitiveDebugLoggingEnabled
|
||||
})
|
||||
|
||||
checkCachedDatabaseVersion(context)
|
||||
|
@ -391,8 +378,8 @@ object K9 : KoinComponent {
|
|||
@JvmStatic
|
||||
fun loadPrefs(prefs: Preferences) {
|
||||
val storage = prefs.storage
|
||||
isDebug = storage.getBoolean("enableDebugLogging", DEVELOPER_MODE)
|
||||
DEBUG_SENSITIVE = storage.getBoolean("enableSensitiveLogging", false)
|
||||
isDebugLoggingEnabled = storage.getBoolean("enableDebugLogging", DEVELOPER_MODE)
|
||||
isSensitiveDebugLoggingEnabled = storage.getBoolean("enableSensitiveLogging", false)
|
||||
isShowAnimations = storage.getBoolean("animations", true)
|
||||
isGesturesEnabled = storage.getBoolean("gesturesEnabled", false)
|
||||
isUseVolumeKeysForNavigation = storage.getBoolean("useVolumeKeysForNavigation", false)
|
||||
|
@ -512,8 +499,8 @@ object K9 : KoinComponent {
|
|||
|
||||
@JvmStatic
|
||||
fun save(editor: StorageEditor) {
|
||||
editor.putBoolean("enableDebugLogging", DEBUG)
|
||||
editor.putBoolean("enableSensitiveLogging", DEBUG_SENSITIVE)
|
||||
editor.putBoolean("enableDebugLogging", isDebugLoggingEnabled)
|
||||
editor.putBoolean("enableSensitiveLogging", isSensitiveDebugLoggingEnabled)
|
||||
editor.putString("backgroundOperations", K9.backgroundOps.name)
|
||||
editor.putBoolean("animations", isShowAnimations)
|
||||
editor.putBoolean("gesturesEnabled", isGesturesEnabled)
|
||||
|
@ -584,8 +571,7 @@ object K9 : KoinComponent {
|
|||
|
||||
private fun updateLoggingStatus() {
|
||||
Timber.uprootAll()
|
||||
val enableDebugLogging = BuildConfig.DEBUG || DEBUG
|
||||
if (enableDebugLogging) {
|
||||
if (isDebugLoggingEnabled) {
|
||||
Timber.plant(DebugTree())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2118,7 +2118,7 @@ public class LocalFolder extends Folder<LocalMessage> {
|
|||
String messagePartId = cursor.getString(0);
|
||||
File file = localStore.getAttachmentFile(messagePartId);
|
||||
if (file.exists()) {
|
||||
if (!file.delete() && K9.isDebug()) {
|
||||
if (!file.delete() && K9.isDebugLoggingEnabled()) {
|
||||
Timber.d("Couldn't delete message part file: %s", file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ public class LocalStore {
|
|||
}
|
||||
|
||||
public void compact() throws MessagingException {
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
Timber.i("Before compaction size = %d", getSize());
|
||||
}
|
||||
|
||||
|
@ -296,20 +296,20 @@ public class LocalStore {
|
|||
}
|
||||
});
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
Timber.i("After compaction size = %d", getSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void clear() throws MessagingException {
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
Timber.i("Before prune size = %d", getSize());
|
||||
}
|
||||
|
||||
deleteAllMessageDataFromDisk();
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
Timber.i("After prune / before compaction size = %d", getSize());
|
||||
Timber.i("Before clear folder count = %d", getFolderCount());
|
||||
Timber.i("Before clear message count = %d", getMessageCount());
|
||||
|
@ -335,7 +335,7 @@ public class LocalStore {
|
|||
|
||||
compact();
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
Timber.i("After clear message count = %d", getMessageCount());
|
||||
Timber.i("After clear size = %d", getSize());
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ public class LockableDatabase {
|
|||
lockRead();
|
||||
final boolean doTransaction = transactional && inTransaction.get() == null;
|
||||
try {
|
||||
final boolean debug = K9.isDebug();
|
||||
final boolean debug = K9.isDebugLoggingEnabled();
|
||||
if (doTransaction) {
|
||||
inTransaction.set(Boolean.TRUE);
|
||||
mDb.beginTransaction();
|
||||
|
|
|
@ -47,7 +47,7 @@ class TextBodyBuilder {
|
|||
if (mIncludeQuotedText) {
|
||||
InsertableHtmlContent quotedHtmlContent = getQuotedTextHtml();
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
Timber.d("insertable: %s", quotedHtmlContent.toDebugString());
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ public class Settings {
|
|||
T defaultValue = setting.getDefaultValue();
|
||||
validatedSettingsMutable.put(settingName, defaultValue);
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
String prettyValue = setting.toPrettyString(defaultValue);
|
||||
Timber.v("Added new setting \"%s\" with default value \"%s\"", settingName, prettyValue);
|
||||
}
|
||||
|
|
|
@ -627,9 +627,9 @@ public class SettingsImporter {
|
|||
* The new value for the preference.
|
||||
*/
|
||||
private static void putString(StorageEditor editor, String key, String value) {
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
String outputValue = value;
|
||||
if (!K9.DEBUG_SENSITIVE && (key.endsWith(".transportUri") || key.endsWith(".storeUri"))) {
|
||||
if (!K9.isSensitiveDebugLoggingEnabled() && (key.endsWith(".transportUri") || key.endsWith(".storeUri"))) {
|
||||
outputValue = "*sensitive*";
|
||||
}
|
||||
Timber.v("Setting %s=%s", key, outputValue);
|
||||
|
|
|
@ -110,7 +110,7 @@ public class AttachmentTempFileProvider extends FileProvider {
|
|||
allFilesDeleted = false;
|
||||
}
|
||||
} else {
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
String timeLeftStr = String.format(
|
||||
Locale.ENGLISH, "%.2f", (lastModified - deletionThreshold) / 1000 / 60.0);
|
||||
Timber.e("Not deleting temp file (for another %s minutes)", timeLeftStr);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class DecryptedFileProvider extends FileProvider {
|
|||
allFilesDeleted = false;
|
||||
}
|
||||
} else {
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
String timeLeftStr = String.format(
|
||||
Locale.ENGLISH, "%.2f", (lastModified - deletionThreshold) / 1000 / 60.0);
|
||||
Timber.e("Not deleting temp file (for another %s minutes)", timeLeftStr);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MigrationTest extends K9RobolectricTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
K9.setDebug(true);
|
||||
K9.setDebugLoggingEnabled(true);
|
||||
ShadowLog.stream = System.out;
|
||||
ShadowSQLiteConnection.reset();
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ class GeneralSettingsDataStore(
|
|||
"disable_notifications_during_quiet_time" -> !K9.isNotificationDuringQuietTimeEnabled
|
||||
"privacy_hide_useragent" -> K9.isHideUserAgent
|
||||
"privacy_hide_timezone" -> K9.isHideTimeZone
|
||||
"debug_logging" -> K9.isDebug
|
||||
"sensitive_logging" -> K9.DEBUG_SENSITIVE
|
||||
"debug_logging" -> K9.isDebugLoggingEnabled
|
||||
"sensitive_logging" -> K9.isSensitiveDebugLoggingEnabled
|
||||
else -> defValue
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ class GeneralSettingsDataStore(
|
|||
"disable_notifications_during_quiet_time" -> K9.isNotificationDuringQuietTimeEnabled = !value
|
||||
"privacy_hide_useragent" -> K9.isHideUserAgent = value
|
||||
"privacy_hide_timezone" -> K9.isHideTimeZone = value
|
||||
"debug_logging" -> K9.isDebug = value
|
||||
"sensitive_logging" -> K9.DEBUG_SENSITIVE = value
|
||||
"debug_logging" -> K9.isDebugLoggingEnabled = value
|
||||
"sensitive_logging" -> K9.isSensitiveDebugLoggingEnabled = value
|
||||
else -> return
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ActivityListenerTest extends RobolectricTest {
|
|||
|
||||
String operation = activityListener.getOperation(context);
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
assertEquals("Polling and pushing disabled", operation);
|
||||
} else {
|
||||
assertEquals("Syncing disabled", operation);
|
||||
|
@ -89,7 +89,7 @@ public class ActivityListenerTest extends RobolectricTest {
|
|||
|
||||
String operation = activityListener.getOperation(context);
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
assertEquals("Polling and pushing disabled", operation);
|
||||
} else {
|
||||
assertEquals("Syncing disabled", operation);
|
||||
|
@ -103,7 +103,7 @@ public class ActivityListenerTest extends RobolectricTest {
|
|||
|
||||
String operation = activityListener.getOperation(context);
|
||||
|
||||
if (K9.isDebug()) {
|
||||
if (K9.isDebugLoggingEnabled()) {
|
||||
assertEquals("Polling and pushing disabled", operation);
|
||||
} else {
|
||||
assertEquals("Syncing disabled", operation);
|
||||
|
|
Loading…
Reference in a new issue