From 0b9decdf42ff910ffc04c0f90e8b836b1c8ac583 Mon Sep 17 00:00:00 2001 From: Philip Whitehouse Date: Sat, 18 Mar 2017 18:08:46 +0000 Subject: [PATCH] Fixing string concat in Timber logging --- .../k9/mail/store/imap/ImapConnection.java | 2 +- .../fsck/k9/mail/store/imap/ImapFolder.java | 33 +++++++------- .../k9/mail/store/imap/ImapFolderPusher.java | 43 +++++++++---------- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapConnection.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapConnection.java index 301c9312c..ac044e220 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapConnection.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapConnection.java @@ -555,7 +555,7 @@ class ImapConnection { } if (K9MailLib.isDebug()) { - Timber.d("useCompression " + useCompression); + Timber.d("useCompression: %b"); } return useCompression; diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java index 398548f22..44bbb8347 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java @@ -353,8 +353,8 @@ class ImapFolder extends Folder { // operation fails. This will save a roundtrip if the folder already exists. if (!exists(escapedDestinationFolderName)) { if (K9MailLib.isDebug()) { - Timber.i("ImapFolder.copyMessages: attempting to create remote folder '" + - escapedDestinationFolderName + "' for " + getLogId()); + Timber.i("ImapFolder.copyMessages: attempting to create remote folder '%s' for %s", + escapedDestinationFolderName, getLogId()); } imapFolder.create(FolderType.HOLDS_MESSAGES); @@ -406,16 +406,16 @@ class ImapFolder extends Folder { if (!exists(escapedTrashFolderName)) { if (K9MailLib.isDebug()) { - Timber.i("IMAPMessage.delete: attempting to create remote '" + trashFolderName + "' folder " + - "for " + getLogId()); + Timber.i("IMAPMessage.delete: attempting to create remote '%s' folder for %s", + trashFolderName, getLogId()); } remoteTrashFolder.create(FolderType.HOLDS_MESSAGES); } if (exists(escapedTrashFolderName)) { if (K9MailLib.isDebug()) { - Timber.d("IMAPMessage.delete: copying remote " + messages.size() + " messages to '" + - trashFolderName + "' for " + getLogId()); + Timber.d("IMAPMessage.delete: copying remote %d messages to '%s' for %s", + messages.size(), trashFolderName, getLogId()); } moveMessages(messages, remoteTrashFolder); @@ -727,18 +727,17 @@ class ImapFolder extends Folder { try { msgSeqUidMap.put(msgSeq, uid); if (K9MailLib.isDebug()) { - Timber.v("Stored uid '" + uid + "' for msgSeq " + msgSeq + " into map"); + Timber.v("Stored uid '%s' for msgSeq %d into map", uid, msgSeq); } } catch (Exception e) { - Timber.e("Unable to store uid '" + uid + "' for msgSeq " + msgSeq); + Timber.e("Unable to store uid '%s' for msgSeq %d", uid, msgSeq); } } Message message = messageMap.get(uid); if (message == null) { if (K9MailLib.isDebug()) { - Timber.d("Do not have message in messageMap for UID " + uid + " for " + - getLogId()); + Timber.d("Do not have message in messageMap for UID %s for %s", uid, getLogId()); } handleUntaggedResponse(response); @@ -812,7 +811,7 @@ class ImapFolder extends Folder { if (!message.getUid().equals(uid)) { if (K9MailLib.isDebug()) { - Timber.d("Did not ask for UID " + uid + " for " + getLogId()); + Timber.d("Did not ask for UID %s for %s", uid, getLogId()); } handleUntaggedResponse(response); @@ -948,7 +947,7 @@ class ImapFolder extends Folder { if ("UIDNEXT".equalsIgnoreCase(key)) { uidNext = bracketed.getLong(1); if (K9MailLib.isDebug()) { - Timber.d("Got UidNext = " + uidNext + " for " + getLogId()); + Timber.d("Got UidNext = %s for %s", uidNext, getLogId()); } } } @@ -965,7 +964,7 @@ class ImapFolder extends Folder { if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXISTS")) { messageCount = response.getNumber(0); if (K9MailLib.isDebug()) { - Timber.d("Got untagged EXISTS with value " + messageCount + " for " + getLogId()); + Timber.d("Got untagged EXISTS with value %d for %s", messageCount, getLogId()); } } @@ -974,7 +973,7 @@ class ImapFolder extends Folder { if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXPUNGE") && messageCount > 0) { messageCount--; if (K9MailLib.isDebug()) { - Timber.d("Got untagged EXPUNGE with messageCount " + messageCount + " for " + getLogId()); + Timber.d("Got untagged EXPUNGE with messageCount %d for %s", messageCount, getLogId()); } } } @@ -1203,7 +1202,7 @@ class ImapFolder extends Folder { */ String newUid = getUidFromMessageId(message); if (K9MailLib.isDebug()) { - Timber.d("Got UID " + newUid + " for message for " + getLogId()); + Timber.d("Got UID %s for message for %s", newUid, getLogId()); } if (!TextUtils.isEmpty(newUid)) { @@ -1234,14 +1233,14 @@ class ImapFolder extends Folder { if (messageIdHeader.length == 0) { if (K9MailLib.isDebug()) { - Timber.d("Did not get a message-id in order to search for UID for " + getLogId()); + Timber.d("Did not get a message-id in order to search for UID for %s", getLogId()); } return null; } String messageId = messageIdHeader[0]; if (K9MailLib.isDebug()) { - Timber.d("Looking for UID for message with message-id " + messageId + " for " + getLogId()); + Timber.d("Looking for UID for message with message-id %s for %s", messageId, getLogId()); } String command = String.format("UID SEARCH HEADER MESSAGE-ID %s", ImapUtility.encodeString(messageId)); diff --git a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolderPusher.java b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolderPusher.java index 66bafbecf..b1ec9853a 100644 --- a/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolderPusher.java +++ b/k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolderPusher.java @@ -88,12 +88,12 @@ class ImapFolderPusher extends ImapFolder { ImapConnection conn = connection; if (conn != null) { if (K9MailLib.isDebug()) { - Timber.v("Closing connection to stop pushing for " + getLogId()); + Timber.v("Closing connection to stop pushing for %s", getLogId()); } conn.close(); } else { - Timber.w("Attempt to interrupt null connection to stop pushing on folderPusher for " + getLogId()); + Timber.w("Attempt to interrupt null connection to stop pushing on folderPusher for %s", getLogId()); } } @@ -105,7 +105,7 @@ class ImapFolderPusher extends ImapFolder { equalsIgnoreCase(responseType, "EXISTS")) { if (K9MailLib.isDebug()) { - Timber.d("Storing response " + response + " for later processing"); + Timber.d("Storing response %s for later processing", response); } synchronized (storedUntaggedResponses) { @@ -132,7 +132,7 @@ class ImapFolderPusher extends ImapFolder { wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT); if (K9MailLib.isDebug()) { - Timber.i("Pusher starting for " + getLogId()); + Timber.i("Pusher starting for %s", getLogId()); } long lastUidNext = -1L; @@ -177,7 +177,7 @@ class ImapFolderPusher extends ImapFolder { processStoredUntaggedResponses(); if (K9MailLib.isDebug()) { - Timber.i("About to IDLE for " + getLogId()); + Timber.i("About to IDLE for %s", getLogId()); } prepareForIdle(); @@ -201,10 +201,10 @@ class ImapFolderPusher extends ImapFolder { reacquireWakeLockAndCleanUp(); if (stop) { - Timber.i("Got exception while idling, but stop is set for " + getLogId()); + Timber.i("Got exception while idling, but stop is set for %s", getLogId()); } else { pushReceiver.pushError("Push error for " + getName(), e); - Timber.e("Got exception while idling for " + getLogId(), e); + Timber.e("Got exception while idling for %s", getLogId()); pushReceiver.sleep(wakeLock, delayTime); @@ -215,8 +215,7 @@ class ImapFolderPusher extends ImapFolder { idleFailureCount++; if (idleFailureCount > IDLE_FAILURE_COUNT_LIMIT) { - Timber.e("Disabling pusher for " + getLogId() + " after " + idleFailureCount + - " consecutive errors"); + Timber.e("Disabling pusher for %s after %d consecutive errors", getLogId(), idleFailureCount); pushReceiver.pushError("Push disabled for " + getName() + " after " + idleFailureCount + " consecutive errors", e); stop = true; @@ -229,12 +228,12 @@ class ImapFolderPusher extends ImapFolder { try { if (K9MailLib.isDebug()) { - Timber.i("Pusher for " + getLogId() + " is exiting"); + Timber.i("Pusher for %s is exiting", getLogId()); } close(); } catch (Exception me) { - Timber.e("Got exception while closing for " + getLogId(), me); + Timber.e(me, "Got exception while closing for %s", getLogId()); } finally { wakeLock.release(); } @@ -250,7 +249,7 @@ class ImapFolderPusher extends ImapFolder { try { connection.close(); } catch (Exception me) { - Timber.e("Got exception while closing for exception for " + getLogId(), me); + Timber.e(me, "Got exception while closing for exception for %s", getLogId()); } connection = null; @@ -274,7 +273,7 @@ class ImapFolderPusher extends ImapFolder { newUidNext = highestUid + 1; if (K9MailLib.isDebug()) { - Timber.d("highest UID = " + highestUid + ", set newUidNext to " + newUidNext); + Timber.d("highest UID = %d, set newUidNext to %d", highestUid, newUidNext); } return newUidNext; @@ -364,12 +363,12 @@ class ImapFolderPusher extends ImapFolder { @Override public void handleAsyncUntaggedResponse(ImapResponse response) { if (K9MailLib.isDebug()) { - Timber.v("Got async response: " + response); + Timber.v("Got async response: %s", response); } if (stop) { if (K9MailLib.isDebug()) { - Timber.d("Got async untagged response: " + response + ", but stop is set for " + getLogId()); + Timber.d("Got async untagged response: %s, but stop is set for %s", response, getLogId()); } idleStopper.stopIdle(); @@ -383,14 +382,14 @@ class ImapFolderPusher extends ImapFolder { wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT); if (K9MailLib.isDebug()) { - Timber.d("Got useful async untagged response: " + response + " for " + getLogId()); + Timber.d("Got useful async untagged response: %s for %s", response, getLogId()); } idleStopper.stopIdle(); } } else if (response.isContinuationRequested()) { if (K9MailLib.isDebug()) { - Timber.d("Idling " + getLogId()); + Timber.d("Idling %s", getLogId()); } idleStopper.startAcceptingDoneContinuation(connection); @@ -414,8 +413,8 @@ class ImapFolderPusher extends ImapFolder { } if (K9MailLib.isDebug()) { - Timber.i("Processing " + untaggedResponses.size() + " untagged responses from previous " + - "commands for " + getLogId()); + Timber.i("Processing %d untagged responses from previous commands for %s", + untaggedResponses.size(), getLogId()); } processUntaggedResponses(untaggedResponses); @@ -461,7 +460,7 @@ class ImapFolderPusher extends ImapFolder { } if (K9MailLib.isDebug()) { - Timber.d("UIDs for messages needing flag sync are " + flagSyncMsgSeqs + " for " + getLogId()); + Timber.d("UIDs for messages needing flag sync are %s for %s", flagSyncMsgSeqs, getLogId()); } if (!flagSyncMsgSeqs.isEmpty()) { @@ -487,7 +486,7 @@ class ImapFolderPusher extends ImapFolder { long msgSeq = response.getLong(0); if (K9MailLib.isDebug()) { - Timber.d("Got untagged FETCH for msgseq " + msgSeq + " for " + getLogId()); + Timber.d("Got untagged FETCH for msgseq %d for %s", msgSeq, getLogId()); } if (!flagSyncMsgSeqs.contains(msgSeq)) { @@ -502,7 +501,7 @@ class ImapFolderPusher extends ImapFolder { } if (K9MailLib.isDebug()) { - Timber.d("Got untagged EXPUNGE for msgseq " + msgSeq + " for " + getLogId()); + Timber.d("Got untagged EXPUNGE for msgseq %d for %s", msgSeq, getLogId()); } List newSeqs = new ArrayList();