Fixing remaining Timber errors in k9mail-library

This commit is contained in:
Philip Whitehouse 2017-03-18 18:36:31 +00:00 committed by Vincent Breitmoser
parent f7c4b0e7c4
commit ad1328d775
15 changed files with 54 additions and 56 deletions

View file

@ -1048,7 +1048,7 @@ public class MimeUtility {
} }
}; };
} else { } else {
Timber.w("Unsupported encoding: " + encoding); Timber.w("Unsupported encoding: %s", encoding);
inputStream = rawInputStream; inputStream = rawInputStream;
} }
} else { } else {

View file

@ -20,7 +20,7 @@ public class XOAuth2ChallengeParser {
String decodedResponse = Base64.decode(response); String decodedResponse = Base64.decode(response);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.v("Challenge response: " + decodedResponse); Timber.v("Challenge response: %s", decodedResponse);
} }
try { try {
@ -30,7 +30,7 @@ public class XOAuth2ChallengeParser {
return false; return false;
} }
} catch (JSONException jsonException) { } catch (JSONException jsonException) {
Timber.e("Error decoding JSON response from: " + host + ". Response was: " + decodedResponse); Timber.e("Error decoding JSON response from: %s. Response was: %s", host, decodedResponse);
} }
return true; return true;

View file

@ -55,7 +55,7 @@ public class TracingPowerManager {
wakeLock = pm.newWakeLock(flags, tag); wakeLock = pm.newWakeLock(flags, tag);
id = wakeLockId.getAndIncrement(); id = wakeLockId.getAndIncrement();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.v("TracingWakeLock for tag " + tag + " / id " + id + ": Create"); Timber.v("TracingWakeLock for tag %s / id %d: Create", tag, id);
} }
} }
public void acquire(long timeout) { public void acquire(long timeout) {
@ -63,7 +63,7 @@ public class TracingPowerManager {
wakeLock.acquire(timeout); wakeLock.acquire(timeout);
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.v("TracingWakeLock for tag " + tag + " / id " + id + " for " + timeout + " ms: acquired"); Timber.v("TracingWakeLock for tag %s / id %d for %d ms: acquired", tag, id, timeout);
} }
raiseNotification(); raiseNotification();
if (startTime == null) { if (startTime == null) {
@ -77,7 +77,8 @@ public class TracingPowerManager {
} }
raiseNotification(); raiseNotification();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.w("TracingWakeLock for tag " + tag + " / id " + id + ": acquired with no timeout. K-9 Mail should not do this"); Timber.w("TracingWakeLock for tag %s / id %d: acquired with no timeout. K-9 Mail should not do this",
tag, id);
} }
if (startTime == null) { if (startTime == null) {
startTime = SystemClock.elapsedRealtime(); startTime = SystemClock.elapsedRealtime();
@ -93,11 +94,12 @@ public class TracingPowerManager {
if (startTime != null) { if (startTime != null) {
Long endTime = SystemClock.elapsedRealtime(); Long endTime = SystemClock.elapsedRealtime();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.v("TracingWakeLock for tag " + tag + " / id " + id + ": releasing after " + (endTime - startTime) + " ms, timeout = " + timeout + " ms"); Timber.v("TracingWakeLock for tag %s / id %d: releasing after %d ms, timeout = %d ms",
tag, id, endTime - startTime, timeout);
} }
} else { } else {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.v("TracingWakeLock for tag " + tag + " / id " + id + ", timeout = " + timeout + " ms: releasing"); Timber.v("TracingWakeLock for tag %s / id %d, timeout = %d ms: releasing", tag, id, timeout);
} }
} }
cancelNotification(); cancelNotification();
@ -127,11 +129,12 @@ public class TracingPowerManager {
public void run() { public void run() {
if (startTime != null) { if (startTime != null) {
Long endTime = SystemClock.elapsedRealtime(); Long endTime = SystemClock.elapsedRealtime();
Timber.i("TracingWakeLock for tag " + tag + " / id " + id + ": has been active for " Timber.i("TracingWakeLock for tag %s / id %d: has been active for %d ms, timeout = %d ms",
+ (endTime - startTime) + " ms, timeout = " + timeout + " ms"); tag, id, endTime - startTime, timeout);
} else { } else {
Timber.i("TracingWakeLock for tag " + tag + " / id " + id + ": still active, timeout = " + timeout + " ms"); Timber.i("TracingWakeLock for tag %s / id %d: still active, timeout = %d ms",
tag, id, timeout);
} }
} }

View file

@ -203,10 +203,10 @@ class KeyChainKeyManager extends X509ExtendedKeyManager {
return mAlias; return mAlias;
} }
} }
Timber.w("Client certificate " + mAlias + " not issued by any of the requested issuers"); Timber.w("Client certificate %s not issued by any of the requested issuers", mAlias);
return null; return null;
} }
Timber.w("Client certificate " + mAlias + " does not match any of the requested key types"); Timber.w("Client certificate %s does not match any of the requested key types", mAlias);
return null; return null;
} }
} }

View file

@ -75,7 +75,7 @@ public class LocalKeyStore {
* Keystore.load. Instead, we let it be created anew. * Keystore.load. Instead, we let it be created anew.
*/ */
if (file.exists() && !file.delete()) { if (file.exists() && !file.delete()) {
Timber.d("Failed to delete empty keystore file: " + file.getAbsolutePath()); Timber.d("Failed to delete empty keystore file: %s", file.getAbsolutePath());
} }
} }
@ -178,7 +178,7 @@ public class LocalKeyStore {
// Blow away version "0" because certificate aliases have changed. // Blow away version "0" because certificate aliases have changed.
File versionZeroFile = new File(getKeyStoreFilePath(0)); File versionZeroFile = new File(getKeyStoreFilePath(0));
if (versionZeroFile.exists() && !versionZeroFile.delete()) { if (versionZeroFile.exists() && !versionZeroFile.delete()) {
Timber.d("Failed to delete old key-store file: " + versionZeroFile.getAbsolutePath()); Timber.d("Failed to delete old key-store file: %s", versionZeroFile.getAbsolutePath());
} }
} }
} }

View file

@ -555,7 +555,7 @@ class ImapConnection {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.d("useCompression: %b"); Timber.d("useCompression: %b", useCompression);
} }
return useCompression; return useCompression;

View file

@ -481,7 +481,7 @@ class ImapFolderPusher extends ImapFolder {
try { try {
Object responseType = response.get(1); Object responseType = response.get(1);
if (equalsIgnoreCase(responseType, "FETCH")) { if (equalsIgnoreCase(responseType, "FETCH")) {
Timber.i("Got FETCH " + response); Timber.i("Got FETCH %s", response);
long msgSeq = response.getLong(0); long msgSeq = response.getLong(0);
@ -548,7 +548,7 @@ class ImapFolderPusher extends ImapFolder {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Timber.e("Could not handle untagged FETCH for " + getLogId(), e); Timber.e(e, "Could not handle untagged FETCH for %s", getLogId());
} }
} }

View file

@ -86,12 +86,11 @@ class ImapResponseParser {
response = readResponse(); response = readResponse();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Timber.v(logId + "<<<" + response); Timber.v("%s<<<%s", logId, response);
} }
if (response.getTag() != null && !response.getTag().equalsIgnoreCase(tag)) { if (response.getTag() != null && !response.getTag().equalsIgnoreCase(tag)) {
Timber.w("After sending tag " + tag + ", got tag response from previous command " + response + Timber.w("After sending tag %s, got tag response from previous command %s for %s", tag, response, logId);
" for " + logId);
Iterator<ImapResponse> responseIterator = responses.iterator(); Iterator<ImapResponse> responseIterator = responses.iterator();

View file

@ -180,8 +180,9 @@ public class ImapStore extends RemoteStore {
try { try {
decodedFolderName = folderNameCodec.decode(listResponse.getName()); decodedFolderName = folderNameCodec.decode(listResponse.getName());
} catch (CharacterCodingException e) { } catch (CharacterCodingException e) {
Timber.w("Folder name not correctly encoded with the UTF-7 variant " + Timber.w(e,
"as defined by RFC 3501: " + listResponse.getName(), e); "Folder name not correctly encoded with the UTF-7 variant as defined by RFC 3501: %s",
listResponse.getName());
//TODO: Use the raw name returned by the server for all commands that require //TODO: Use the raw name returned by the server for all commands that require
// a folder name. Use the decoded name only for showing it to the user. // a folder name. Use the decoded name only for showing it to the user.
@ -255,8 +256,8 @@ public class ImapStore extends RemoteStore {
try { try {
decodedFolderName = folderNameCodec.decode(listResponse.getName()); decodedFolderName = folderNameCodec.decode(listResponse.getName());
} catch (CharacterCodingException e) { } catch (CharacterCodingException e) {
Timber.w("Folder name not correctly encoded with the UTF-7 variant " + Timber.w(e, "Folder name not correctly encoded with the UTF-7 variant as defined by RFC 3501: %s",
"as defined by RFC 3501: " + listResponse.getName(), e); listResponse.getName());
// We currently just skip folders with malformed names. // We currently just skip folders with malformed names.
continue; continue;
} }
@ -269,27 +270,27 @@ public class ImapStore extends RemoteStore {
if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) { if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) {
mStoreConfig.setArchiveFolderName(decodedFolderName); mStoreConfig.setArchiveFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.d("Folder auto-configuration detected Archive folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Archive folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Drafts")) { } else if (listResponse.hasAttribute("\\Drafts")) {
mStoreConfig.setDraftsFolderName(decodedFolderName); mStoreConfig.setDraftsFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.d("Folder auto-configuration detected Drafts folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Drafts folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Sent")) { } else if (listResponse.hasAttribute("\\Sent")) {
mStoreConfig.setSentFolderName(decodedFolderName); mStoreConfig.setSentFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.d("Folder auto-configuration detected Sent folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Sent folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Junk")) { } else if (listResponse.hasAttribute("\\Junk")) {
mStoreConfig.setSpamFolderName(decodedFolderName); mStoreConfig.setSpamFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.d("Folder auto-configuration detected Spam folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Spam folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Trash")) { } else if (listResponse.hasAttribute("\\Trash")) {
mStoreConfig.setTrashFolderName(decodedFolderName); mStoreConfig.setTrashFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Timber.d("Folder auto-configuration detected Trash folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Trash folder: %s", decodedFolderName);
} }
} }
} }

View file

@ -100,12 +100,12 @@ class ImapUtility {
} }
} }
} else { } else {
Timber.d("Invalid range: " + range); Timber.d("Invalid range: %s", range);
} }
} }
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Timber.d("Invalid range value: " + range, e); Timber.d(e, "Invalid range value: %s", range);
} }
return list; return list;
@ -121,7 +121,7 @@ class ImapUtility {
// do nothing // do nothing
} }
Timber.d("Invalid UID value: " + number); Timber.d("Invalid UID value: %s", number);
return false; return false;
} }

View file

@ -661,7 +661,7 @@ public class Pop3Store extends RemoteStore {
// response = "+OK msgNum msgUid" // response = "+OK msgNum msgUid"
String[] uidParts = response.split(" +"); String[] uidParts = response.split(" +");
if (uidParts.length < 3 || !"+OK".equals(uidParts[0])) { if (uidParts.length < 3 || !"+OK".equals(uidParts[0])) {
Timber.e("ERR response: " + response); Timber.e("ERR response: %s", response);
return; return;
} }
String msgUid = uidParts[2]; String msgUid = uidParts[2];
@ -720,7 +720,7 @@ public class Pop3Store extends RemoteStore {
for (String uid : uids) { for (String uid : uids) {
if (mUidToMsgMap.get(uid) == null) { if (mUidToMsgMap.get(uid) == null) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Timber.d("Need to index UID " + uid); Timber.d("Need to index UID %s", uid);
} }
unindexedUids.add(uid); unindexedUids.add(uid);
} }
@ -746,7 +746,7 @@ public class Pop3Store extends RemoteStore {
String msgUid = uidParts[1]; String msgUid = uidParts[1];
if (unindexedUids.contains(msgUid)) { if (unindexedUids.contains(msgUid)) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Timber.d("Got msgNum " + msgNum + " for UID " + msgUid); Timber.d("Got msgNum %d for UID %s", msgNum, msgUid);
} }
Pop3Message message = mUidToMsgMap.get(msgUid); Pop3Message message = mUidToMsgMap.get(msgUid);
@ -761,7 +761,7 @@ public class Pop3Store extends RemoteStore {
private void indexMessage(int msgNum, Pop3Message message) { private void indexMessage(int msgNum, Pop3Message message) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Timber.d("Adding index for UID " + message.getUid() + " to msgNum " + msgNum); Timber.d("Adding index for UID %s to msgNum %d", message.getUid(), msgNum);
} }
mMsgNumToMsgMap.put(msgNum, message); mMsgNumToMsgMap.put(msgNum, message);
mUidToMsgMap.put(message.getUid(), message); mUidToMsgMap.put(message.getUid(), message);
@ -1037,7 +1037,7 @@ public class Pop3Store extends RemoteStore {
} while ((d = mIn.read()) != -1); } while ((d = mIn.read()) != -1);
String ret = sb.toString(); String ret = sb.toString();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Timber.d("<<< " + ret); Timber.d("<<< %s", ret);
} }
return ret; return ret;
} }
@ -1131,10 +1131,9 @@ public class Pop3Store extends RemoteStore {
if (command != null) { if (command != null) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
if (sensitive && !K9MailLib.isDebugSensitive()) { if (sensitive && !K9MailLib.isDebugSensitive()) {
Timber.d(">>> " Timber.d(">>> [Command Hidden, Enable Sensitive Debug Logging To Show]");
+ "[Command Hidden, Enable Sensitive Debug Logging To Show]");
} else { } else {
Timber.d(">>> " + command); Timber.d(">>> %s", command);
} }
} }

View file

@ -135,7 +135,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
headers.put("Brief", "t"); headers.put("Brief", "t");
headers.put("If-Match", "*"); headers.put("If-Match", "*");
String action = (isMove ? "BMOVE" : "BCOPY"); String action = (isMove ? "BMOVE" : "BCOPY");
Timber.v("Moving " + messages.size() + " messages to " + destFolder.mFolderUrl); Timber.v("Moving %d messages to %s", messages.size(), destFolder.mFolderUrl);
store.processRequest(mFolderUrl, action, messageBody, headers, false); store.processRequest(mFolderUrl, action, messageBody, headers, false);
} }
@ -159,7 +159,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
messageCount = dataset.getMessageCount(); messageCount = dataset.getMessageCount();
} }
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Timber.v("Counted messages and webdav returned: " + messageCount); Timber.v("Counted messages and webdav returned: %d", messageCount);
} }
return messageCount; return messageCount;
@ -352,16 +352,14 @@ class WebDavFolder extends Folder<WebDavMessage> {
*/ */
if (wdMessage.getUrl().equals("")) { if (wdMessage.getUrl().equals("")) {
wdMessage.setUrl(getMessageUrls(new String[]{wdMessage.getUid()}).get(wdMessage.getUid())); wdMessage.setUrl(getMessageUrls(new String[]{wdMessage.getUid()}).get(wdMessage.getUid()));
Timber.i("Fetching messages with UID = '" + wdMessage.getUid() + "', URL = '" Timber.i("Fetching messages with UID = '%s', URL = '%s'", wdMessage.getUid(), wdMessage.getUrl());
+ wdMessage.getUrl() + "'");
if (wdMessage.getUrl().equals("")) { if (wdMessage.getUrl().equals("")) {
throw new MessagingException("Unable to get URL for message"); throw new MessagingException("Unable to get URL for message");
} }
} }
try { try {
Timber.i("Fetching message with UID = '" + wdMessage.getUid() + "', URL = '" Timber.i("Fetching message with UID = '%s', URL = '%s'", wdMessage.getUid(), wdMessage.getUrl());
+ wdMessage.getUrl() + "'");
HttpGet httpget = new HttpGet(new URI(wdMessage.getUrl())); HttpGet httpget = new HttpGet(new URI(wdMessage.getUrl()));
HttpResponse response; HttpResponse response;
HttpEntity entity; HttpEntity entity;
@ -559,7 +557,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
message.setNewHeaders(envelope); message.setNewHeaders(envelope);
message.setFlagInternal(Flag.SEEN, envelope.getReadStatus()); message.setFlagInternal(Flag.SEEN, envelope.getReadStatus());
} else { } else {
Timber.e("Asked to get metadata for a non-existent message: " + message.getUid()); Timber.e("Asked to get metadata for a non-existent message: %s", message.getUid());
} }
if (listener != null) { if (listener != null) {
@ -673,7 +671,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
} }
messageURL += encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml"); messageURL += encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml");
Timber.i("Uploading message as " + messageURL); Timber.i("Uploading message as %s", messageURL);
store.sendRequest(messageURL, "PUT", bodyEntity, null, true); store.sendRequest(messageURL, "PUT", bodyEntity, null, true);

View file

@ -98,7 +98,7 @@ class WebDavMessage extends MimeMessage {
@Override @Override
public void delete(String trashFolderName) throws MessagingException { public void delete(String trashFolderName) throws MessagingException {
WebDavFolder wdFolder = (WebDavFolder) getFolder(); WebDavFolder wdFolder = (WebDavFolder) getFolder();
Timber.i("Deleting message by moving to " + trashFolderName); Timber.i("Deleting message by moving to %s", trashFolderName);
wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore().getFolder(trashFolderName)); wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore().getFolder(trashFolderName));
} }

View file

@ -924,8 +924,7 @@ public class WebDavStore extends RemoteStore {
throws MessagingException { throws MessagingException {
DataSet dataset = new DataSet(); DataSet dataset = new DataSet();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Timber.v("processRequest url = '" + url + "', method = '" + method + "', messageBody = '" Timber.v("processRequest url = '%s', method = '%s', messageBody = '%s'", url, method, messageBody);
+ messageBody + "'");
} }
if (url == null || if (url == null ||
@ -957,8 +956,7 @@ public class WebDavStore extends RemoteStore {
dataset = myHandler.getDataSet(); dataset = myHandler.getDataSet();
} catch (SAXException se) { } catch (SAXException se) {
Timber.e(se, Timber.e(se, "SAXException in processRequest()");
"SAXException in processRequest()");
throw new MessagingException("SAXException in processRequest() ", se); throw new MessagingException("SAXException in processRequest() ", se);
} catch (ParserConfigurationException pce) { } catch (ParserConfigurationException pce) {
Timber.e(pce, "ParserConfigurationException in processRequest()"); Timber.e(pce, "ParserConfigurationException in processRequest()");

View file

@ -462,7 +462,7 @@ public class SmtpTransport extends Transport {
mLargestAcceptableMessage = Integer.parseInt(optionalsizeValue); mLargestAcceptableMessage = Integer.parseInt(optionalsizeValue);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) {
Timber.d("Tried to parse " + optionalsizeValue + " and get an int", e); Timber.d(e, "Tried to parse %s and get an int", optionalsizeValue);
} }
} }
} }
@ -627,7 +627,7 @@ public class SmtpTransport extends Transport {
} }
String ret = sb.toString(); String ret = sb.toString();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP)
Timber.d("SMTP <<< " + ret); Timber.d("SMTP <<< %s", ret);
return ret; return ret;
} }