Merge pull request #2423 from k9mail/timberLibrary

Move k9mail-library to Timber
This commit is contained in:
cketti 2017-03-26 05:29:03 +02:00 committed by GitHub
commit 3cd7e26bb9
45 changed files with 247 additions and 357 deletions

View file

@ -1,6 +1,7 @@
androidCompileSdkVersion=25
androidBuildToolsVersion=25.0.2
androidSupportLibraryVersion=25.2.0
timberVersion=4.5.1
robolectricVersion=3.2.2
junitVersion=4.12

View file

@ -20,6 +20,7 @@ dependencies {
compile 'com.jcraft:jzlib:1.0.7'
compile 'com.beetstra.jutf7:jutf7:1.0.0'
compile "com.android.support:support-annotations:${androidSupportLibraryVersion}"
compile "com.jakewharton.timber:timber:${timberVersion}"
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0'

View file

@ -12,13 +12,11 @@ import org.apache.james.mime4j.codec.EncoderUtil;
import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.address.MailboxList;
import org.apache.james.mime4j.field.address.AddressBuilder;
import timber.log.Timber;
import android.text.TextUtils;
import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.util.Log;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class Address implements Serializable {
private static final Pattern ATOM = Pattern.compile("^(?:[a-zA-Z0-9!#$%&'*+\\-/=?^_`{|}~]|\\s)+$");
@ -152,12 +150,11 @@ public class Address implements Serializable {
Mailbox mailbox = (Mailbox) address;
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
} else {
Log.e(LOG_TAG, "Unknown address type from Mime4J: "
+ address.getClass().toString());
Timber.e("Unknown address type from Mime4J: %s", address.getClass().toString());
}
}
} catch (MimeException pe) {
Log.e(LOG_TAG, "MimeException in Address.parse()", pe);
Timber.e(pe, "MimeException in Address.parse()");
//but we do an silent failover : we just use the given string as name with empty address
addresses.add(new Address(null, addressList, false));
}

View file

@ -6,9 +6,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import android.util.Log;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public abstract class Folder<T extends Message> {
private String status = null;
@ -133,8 +132,7 @@ public abstract class Folder<T extends Message> {
// This is causing trouble. Disabled for now. See issue 1733
//throw new RuntimeException("fetchPart() not implemented.");
if (K9MailLib.isDebug())
Log.d(LOG_TAG, "fetchPart() not implemented.");
Timber.d("fetchPart() not implemented.");
}
public abstract void delete(boolean recurse) throws MessagingException;

View file

@ -7,7 +7,6 @@ public class K9MailLib {
private K9MailLib() {
}
public static final String LOG_TAG = "k9";
public static final int PUSH_WAKE_LOCK_TIMEOUT = 60000;
public static final String IDENTITY_HEADER = "X-K9mail-Identity";

View file

@ -8,12 +8,11 @@ import java.util.EnumSet;
import java.util.Set;
import android.support.annotation.NonNull;
import android.util.Log;
import com.fsck.k9.mail.filter.CountingOutputStream;
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public abstract class Message implements Part, Body {
@ -208,9 +207,9 @@ public abstract class Message implements Part, Body {
eolOut.flush();
return out.getCount();
} catch (IOException e) {
Log.e(LOG_TAG, "Failed to calculate a message size", e);
Timber.e(e, "Failed to calculate a message size");
} catch (MessagingException e) {
Log.e(LOG_TAG, "Failed to calculate a message size", e);
Timber.e(e, "Failed to calculate a message size");
}
return 0;
}

View file

@ -2,7 +2,6 @@
package com.fsck.k9.mail;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.support.annotation.NonNull;

View file

@ -9,14 +9,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.filter.Base64OutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.codec.QuotedPrintableOutputStream;
import org.apache.james.mime4j.util.MimeUtil;
import timber.log.Timber;
/**
@ -136,7 +134,7 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware {
try {
super.close();
} finally {
Log.d(K9MailLib.LOG_TAG, "deleting temp file");
Timber.d("Deleting temporary binary file");
mFile.delete();
}
}

View file

@ -1,12 +1,11 @@
package com.fsck.k9.mail.internet;
import android.util.Log;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import java.io.IOException;
import java.io.InputStream;
@ -14,7 +13,6 @@ import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.util.Locale;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.internet.JisSupport.SHIFT_JIS;
public class CharsetSupport {
@ -111,8 +109,7 @@ public class CharsetSupport {
}
if (charset.matches(rule[0])) {
Log.e(LOG_TAG, "I don't know how to deal with the charset " + charset +
". Falling back to " + rule[1]);
Timber.e("I don't know how to deal with the charset %s. Falling back to %s", charset, rule[1]);
charset = rule[1];
try {
supported = Charset.isSupported(charset);

View file

@ -1,7 +1,6 @@
package com.fsck.k9.mail.internet;
import android.util.Log;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import java.io.ByteArrayInputStream;
@ -11,8 +10,7 @@ import java.nio.charset.Charset;
import org.apache.james.mime4j.codec.Base64InputStream;
import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
import org.apache.james.mime4j.util.CharsetUtil;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
/**
@ -169,7 +167,7 @@ class DecoderUtil {
}
if (encodedText.isEmpty()) {
Log.w(LOG_TAG, "Missing encoded text in encoded word: '" + body.substring(begin, end) + "'");
Timber.w("Missing encoded text in encoded word: '%s'", body.substring(begin, end));
return null;
}
@ -178,7 +176,7 @@ class DecoderUtil {
} else if (encoding.equalsIgnoreCase("B")) {
return DecoderUtil.decodeB(encodedText, charset);
} else {
Log.w(LOG_TAG, "Warning: Unknown encoding in encoded word '" + body.substring(begin, end) + "'");
Timber.w("Warning: Unknown encoding in encoded word '%s'", body.substring(begin, end));
return null;
}
}

View file

@ -12,7 +12,6 @@ import java.util.regex.Pattern;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
@ -22,8 +21,8 @@ import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.Viewable.Flowed;
import org.apache.commons.io.input.BoundedInputStream;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.internet.CharsetSupport.fixupCharset;
import static com.fsck.k9.mail.internet.MimeUtility.getHeaderParameter;
import static com.fsck.k9.mail.internet.MimeUtility.isFormatFlowed;
@ -62,9 +61,9 @@ public class MessageExtractor {
throw new MessagingException("Provided invalid part");
}
} catch (IOException e) {
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
Timber.e(e, "Unable to getTextFromPart");
} catch (MessagingException e) {
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
Timber.e("Unable to getTextFromPart");
}
return null;
}

View file

@ -9,7 +9,6 @@ import java.util.Locale;
import java.util.regex.Pattern;
import android.support.annotation.NonNull;
import android.util.Log;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
@ -21,8 +20,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.codec.Base64InputStream;
import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
import org.apache.james.mime4j.util.MimeUtil;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
public class MimeUtility {
@ -1050,7 +1048,7 @@ public class MimeUtility {
}
};
} else {
Log.w(LOG_TAG, "Unsupported encoding: " + encoding);
Timber.w("Unsupported encoding: %s", encoding);
inputStream = rawInputStream;
}
} else {

View file

@ -9,15 +9,15 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import android.support.annotation.Nullable;
import android.util.Log;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.filter.CountingOutputStream;
import com.fsck.k9.mail.filter.SignSafeOutputStream;
import org.apache.james.mime4j.codec.QuotedPrintableOutputStream;
import org.apache.james.mime4j.util.MimeUtil;
import timber.log.Timber;
public class TextBody implements Body, SizeAware {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
@ -67,7 +67,7 @@ public class TextBody implements Body, SizeAware {
}
return new ByteArrayInputStream(b);
} catch (UnsupportedEncodingException uee) {
Log.e(K9MailLib.LOG_TAG, "Unsupported charset: " + charset, uee);
Timber.e(uee, "Unsupported charset: %s", charset);
return null;
}
}

View file

@ -1,14 +1,11 @@
package com.fsck.k9.mail.oauth;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.filter.Base64;
import org.json.JSONException;
import org.json.JSONObject;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
/**
@ -23,7 +20,7 @@ public class XOAuth2ChallengeParser {
String decodedResponse = Base64.decode(response);
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Challenge response: " + decodedResponse);
Timber.v("Challenge response: %s", decodedResponse);
}
try {
@ -33,7 +30,7 @@ public class XOAuth2ChallengeParser {
return false;
}
} catch (JSONException jsonException) {
Log.e(LOG_TAG, "Error decoding JSON response from: " + host + ". Response was: " + decodedResponse);
Timber.e("Error decoding JSON response from: %s. Response was: %s", host, decodedResponse);
}
return true;

View file

@ -1,5 +1,6 @@
package com.fsck.k9.mail.power;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger;
@ -8,11 +9,9 @@ import android.content.Context;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
public class TracingPowerManager {
@ -26,7 +25,7 @@ public class TracingPowerManager {
Context appContext = context.getApplicationContext();
if (tracingPowerManager == null) {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Creating TracingPowerManager");
Timber.v("Creating TracingPowerManager");
}
tracingPowerManager = new TracingPowerManager(appContext);
}
@ -56,7 +55,7 @@ public class TracingPowerManager {
wakeLock = pm.newWakeLock(flags, tag);
id = wakeLockId.getAndIncrement();
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": Create");
Timber.v("TracingWakeLock for tag %s / id %d: Create", tag, id);
}
}
public void acquire(long timeout) {
@ -64,7 +63,7 @@ public class TracingPowerManager {
wakeLock.acquire(timeout);
}
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "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();
if (startTime == null) {
@ -78,7 +77,8 @@ public class TracingPowerManager {
}
raiseNotification();
if (K9MailLib.isDebug()) {
Log.w(LOG_TAG, "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) {
startTime = SystemClock.elapsedRealtime();
@ -94,11 +94,12 @@ public class TracingPowerManager {
if (startTime != null) {
Long endTime = SystemClock.elapsedRealtime();
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "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 {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "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();
@ -128,11 +129,12 @@ public class TracingPowerManager {
public void run() {
if (startTime != null) {
Long endTime = SystemClock.elapsedRealtime();
Log.i(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": has been active for "
+ (endTime - startTime) + " ms, timeout = " + timeout + " ms");
Timber.i("TracingWakeLock for tag %s / id %d: has been active for %d ms, timeout = %d ms",
tag, id, endTime - startTime, timeout);
} else {
Log.i(LOG_TAG, "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

@ -13,7 +13,6 @@ import android.content.Context;
import android.net.SSLCertificateSocketFactory;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.mail.MessagingException;
import javax.net.ssl.KeyManager;
@ -21,8 +20,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
/**
@ -113,8 +111,7 @@ public class DefaultTrustedSocketFactory implements TrustedSocketFactory {
*/
supportedProtocols = sock.getSupportedProtocols();
} catch (Exception e) {
Log.e(LOG_TAG, "Error getting information about available SSL/TLS ciphers and " +
"protocols", e);
Timber.e(e, "Error getting information about available SSL/TLS ciphers and protocols");
}
if (hasWeakSslImplementation()) {
@ -232,7 +229,7 @@ public class DefaultTrustedSocketFactory implements TrustedSocketFactory {
try {
socket.getClass().getMethod("setHostname", String.class).invoke(socket, hostname);
} catch (Throwable e) {
Log.e(LOG_TAG, "Could not call SSLSocket#setHostname(String) method ", e);
Timber.e(e, "Could not call SSLSocket#setHostname(String) method ");
}
}
}

View file

@ -18,12 +18,11 @@ import android.content.Context;
import android.os.Build;
import android.security.KeyChain;
import android.security.KeyChainException;
import android.util.Log;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.MessagingException;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.CertificateValidationException.Reason;
import static com.fsck.k9.mail.CertificateValidationException.Reason.RetrievalFailure;
@ -204,10 +203,10 @@ class KeyChainKeyManager extends X509ExtendedKeyManager {
return mAlias;
}
}
Log.w(LOG_TAG, "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;
}
Log.w(LOG_TAG, "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;
}
}

View file

@ -12,10 +12,8 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import android.util.Log;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class LocalKeyStore {
private static final int KEY_STORE_FILE_VERSION = 1;
@ -50,7 +48,7 @@ public class LocalKeyStore {
* error, presuming setKeyStoreFile(File) is called next with a
* non-null File.
*/
Log.w(LOG_TAG, "Local key store has not been initialized");
Timber.w("Local key store has not been initialized");
}
}
@ -77,7 +75,7 @@ public class LocalKeyStore {
* Keystore.load. Instead, we let it be created anew.
*/
if (file.exists() && !file.delete()) {
Log.d(LOG_TAG, "Failed to delete empty keystore file: " + file.getAbsolutePath());
Timber.d("Failed to delete empty keystore file: %s", file.getAbsolutePath());
}
}
@ -94,7 +92,7 @@ public class LocalKeyStore {
mKeyStore = store;
mKeyStoreFile = file;
} catch (Exception e) {
Log.e(LOG_TAG, "Failed to initialize local key store", e);
Timber.e(e, "Failed to initialize local key store");
// Use of the local key store is effectively disabled.
mKeyStore = null;
mKeyStoreFile = null;
@ -171,7 +169,7 @@ public class LocalKeyStore {
} catch (KeyStoreException e) {
// Ignore: most likely there was no cert. found
} catch (CertificateException e) {
Log.e(LOG_TAG, "Error updating the local key store file", e);
Timber.e(e, "Error updating the local key store file");
}
}
@ -180,7 +178,7 @@ public class LocalKeyStore {
// Blow away version "0" because certificate aliases have changed.
File versionZeroFile = new File(getKeyStoreFilePath(0));
if (versionZeroFile.exists() && !versionZeroFile.delete()) {
Log.d(LOG_TAG, "Failed to delete old key-store file: " + versionZeroFile.getAbsolutePath());
Timber.d("Failed to delete old key-store file: %s", versionZeroFile.getAbsolutePath());
}
}
}

View file

@ -1,8 +1,6 @@
package com.fsck.k9.mail.ssl;
import android.util.Log;
import com.fsck.k9.mail.CertificateChainException;
import javax.net.ssl.SSLException;
@ -10,6 +8,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.conn.ssl.StrictHostnameVerifier;
import timber.log.Timber;
import java.security.KeyStore;
import java.security.KeyStoreException;
@ -20,8 +19,6 @@ import java.util.HashMap;
import java.util.Map;
public final class TrustManagerFactory {
private static final String LOG_TAG = "TrustManagerFactory";
private static X509TrustManager defaultTrustManager;
private static LocalKeyStore keyStore;
@ -108,9 +105,9 @@ public final class TrustManagerFactory {
}
}
} catch (NoSuchAlgorithmException e) {
Log.e(LOG_TAG, "Unable to get X509 Trust Manager ", e);
Timber.e(e, "Unable to get X509 Trust Manager ");
} catch (KeyStoreException e) {
Log.e(LOG_TAG, "Key Store exception while initializing TrustManagerFactory ", e);
Timber.e(e, "Key Store exception while initializing TrustManagerFactory");
}
}

View file

@ -3,7 +3,6 @@ package com.fsck.k9.mail.store.imap;
import java.io.IOException;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.filter.FixedLengthInputStream;
import com.fsck.k9.mail.internet.MimeHeader;

View file

@ -28,7 +28,6 @@ import java.util.zip.InflaterInputStream;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import com.fsck.k9.mail.Authentication;
import com.fsck.k9.mail.AuthenticationFailedException;
@ -46,10 +45,10 @@ import com.jcraft.jzlib.JZlib;
import com.jcraft.jzlib.ZOutputStream;
import javax.net.ssl.SSLException;
import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import static com.fsck.k9.mail.ConnectionSecurity.STARTTLS_REQUIRED;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.store.RemoteStore.SOCKET_CONNECT_TIMEOUT;
import static com.fsck.k9.mail.store.RemoteStore.SOCKET_READ_TIMEOUT;
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
@ -141,7 +140,7 @@ class ImapConnection {
throw new MessagingException("Unable to open connection to IMAP server due to security error.", e);
} finally {
if (!authSuccess) {
Log.e(LOG_TAG, "Failed to login, closing connection for " + getLogId());
Timber.e("Failed to login, closing connection for %s", getLogId());
close();
}
}
@ -160,7 +159,7 @@ class ImapConnection {
String[] tokens = message.split("-");
if (tokens.length > 1 && tokens[1] != null) {
Log.e(LOG_TAG, "Stripping host/port from ConnectionException for " + getLogId(), e);
Timber.e(e, "Stripping host/port from ConnectionException for %s", getLogId());
throw new ConnectException(tokens[1].trim());
} else {
throw e;
@ -176,13 +175,13 @@ class ImapConnection {
try {
Security.setProperty("networkaddress.cache.ttl", "0");
} catch (Exception e) {
Log.w(LOG_TAG, "Could not set DNS ttl to 0 for " + getLogId(), e);
Timber.w(e, "Could not set DNS ttl to 0 for %s", getLogId());
}
try {
Security.setProperty("networkaddress.cache.negative.ttl", "0");
} catch (Exception e) {
Log.w(LOG_TAG, "Could not set DNS negative ttl to 0 for " + getLogId(), e);
Timber.w(e, "Could not set DNS negative ttl to 0 for %s", getLogId());
}
}
@ -194,7 +193,7 @@ class ImapConnection {
try {
return connectToAddress(address);
} catch (IOException e) {
Log.w(LOG_TAG, "Could not connect to " + address, e);
Timber.w(e, "Could not connect to %s", address);
connectException = e;
}
}
@ -210,7 +209,7 @@ class ImapConnection {
String clientCertificateAlias = settings.getClientCertificateAlias();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.d(LOG_TAG, "Connecting to " + host + " as " + address);
Timber.d("Connecting to %s as %s", host, address);
}
SocketAddress socketAddress = new InetSocketAddress(address, port);
@ -245,7 +244,7 @@ class ImapConnection {
ImapResponse initialResponse = responseParser.readResponse();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, getLogId() + "<<<" + initialResponse);
Timber.v("%s <<< %s", getLogId(), initialResponse);
}
extractCapabilities(Collections.singletonList(initialResponse));
@ -258,7 +257,7 @@ class ImapConnection {
Set<String> receivedCapabilities = capabilityResponse.getCapabilities();
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Saving " + receivedCapabilities + " capabilities for " + getLogId());
Timber.d("Saving %s capabilities for %s", receivedCapabilities, getLogId());
}
capabilities = receivedCapabilities;
@ -273,7 +272,7 @@ class ImapConnection {
}
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Did not get capabilities in banner, requesting CAPABILITY for " + getLogId());
Timber.i("Did not get capabilities in banner, requesting CAPABILITY for %s", getLogId());
}
requestCapabilities();
@ -320,7 +319,7 @@ class ImapConnection {
// Per RFC 2595 (3.1): Once TLS has been started, reissue CAPABILITY command
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Updating capabilities after STARTTLS for " + getLogId());
Timber.i("Updating capabilities after STARTTLS for %s", getLogId());
}
requestCapabilities();
@ -388,7 +387,7 @@ class ImapConnection {
}
private void handlePermanentXoauth2Failure(NegativeImapResponseException e) throws AuthenticationFailedException {
Log.v(LOG_TAG, "Permanent failure during XOAUTH2", e);
Timber.v(e, "Permanent failure during XOAUTH2");
throw new AuthenticationFailedException(e.getMessage(), e);
}
@ -398,13 +397,13 @@ class ImapConnection {
//if a token was invalid before use (e.g. due to expiry). But we don't
//This is the intended behaviour per AccountManager
Log.v(LOG_TAG, "Temporary failure - retrying with new token", e);
Timber.v(e, "Temporary failure - retrying with new token");
try {
attemptXOAuth2();
} catch (NegativeImapResponseException e2) {
//Okay, we failed on a new token.
//Invalidate the token anyway but assume it's permanent.
Log.v(LOG_TAG, "Authentication exception for new token, permanent error assumed", e);
Timber.v(e, "Authentication exception for new token, permanent error assumed");
oauthTokenProvider.invalidateToken(settings.getUsername());
handlePermanentXoauth2Failure(e2);
}
@ -548,7 +547,7 @@ class ImapConnection {
if (networkInfo != null) {
int type = networkInfo.getType();
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "On network type " + type);
Timber.d("On network type %s", type);
}
NetworkType networkType = NetworkType.fromConnectivityManagerType(type);
@ -556,7 +555,7 @@ class ImapConnection {
}
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "useCompression " + useCompression);
Timber.d("useCompression: %b", useCompression);
}
return useCompression;
@ -566,7 +565,7 @@ class ImapConnection {
try {
executeSimpleCommand(Commands.COMPRESS_DEFLATE);
} catch (NegativeImapResponseException e) {
Log.d(LOG_TAG, "Unable to negotiate compression: " + e.getMessage());
Timber.d(e, "Unable to negotiate compression: ");
return;
}
@ -578,11 +577,11 @@ class ImapConnection {
setUpStreamsAndParser(input, output);
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Compression enabled for " + getLogId());
Timber.i("Compression enabled for %s", getLogId());
}
} catch (IOException e) {
close();
Log.e(LOG_TAG, "Error enabling compression", e);
Timber.e(e, "Error enabling compression");
}
}
@ -593,12 +592,12 @@ class ImapConnection {
if (hasCapability(Capabilities.NAMESPACE)) {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "pathPrefix is unset and server has NAMESPACE capability");
Timber.i("pathPrefix is unset and server has NAMESPACE capability");
}
handleNamespace();
} else {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "pathPrefix is unset but server does not have NAMESPACE capability");
Timber.i("pathPrefix is unset but server does not have NAMESPACE capability");
}
settings.setPathPrefix("");
}
@ -617,7 +616,7 @@ class ImapConnection {
settings.setCombinedPrefix(null);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got path '" + prefix + "' and separator '" + hierarchyDelimiter + "'");
Timber.d("Got path '%s' and separator '%s'", prefix, hierarchyDelimiter);
}
}
}
@ -633,7 +632,7 @@ class ImapConnection {
try {
listResponses = executeSimpleCommand(Commands.LIST + " \"\" \"\"");
} catch (NegativeImapResponseException e) {
Log.d(LOG_TAG, "Error getting path delimiter using LIST command", e);
Timber.d(e, "Error getting path delimiter using LIST command");
return;
}
@ -644,7 +643,7 @@ class ImapConnection {
settings.setCombinedPrefix(null);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got path delimiter '" + settings.getPathDelimiter() + "' for " + getLogId());
Timber.d("Got path delimiter '%s' for %s", settings.getPathDelimiter(), getLogId());
}
break;
@ -670,7 +669,7 @@ class ImapConnection {
protected boolean isIdleCapable() {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Connection " + getLogId() + " has " + capabilities.size() + " capabilities");
Timber.v("Connection %s has %d capabilities", getLogId(), capabilities.size());
}
return capabilities.contains(Capabilities.IDLE);
@ -736,9 +735,9 @@ class ImapConnection {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
if (sensitive && !K9MailLib.isDebugSensitive()) {
Log.v(LOG_TAG, getLogId() + ">>> [Command Hidden, Enable Sensitive Debug Logging To Show]");
Timber.v("%s>>> [Command Hidden, Enable Sensitive Debug Logging To Show]", getLogId());
} else {
Log.v(LOG_TAG, getLogId() + ">>> " + tag + " " + command + " " + initialClientResponse);
Timber.v("%s>>> %s %s %s", getLogId(), tag, command, initialClientResponse);
}
}
@ -760,9 +759,9 @@ class ImapConnection {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
if (sensitive && !K9MailLib.isDebugSensitive()) {
Log.v(LOG_TAG, getLogId() + ">>> [Command Hidden, Enable Sensitive Debug Logging To Show]");
Timber.v("%s>>> [Command Hidden, Enable Sensitive Debug Logging To Show]", getLogId());
} else {
Log.v(LOG_TAG, getLogId() + ">>> " + tag + " " + command);
Timber.v("%s>>> %s %s", getLogId(), tag, command);
}
}
@ -780,7 +779,7 @@ class ImapConnection {
outputStream.flush();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, getLogId() + ">>> " + continuation);
Timber.v("%s>>> %s", getLogId(), continuation);
}
}
@ -793,7 +792,7 @@ class ImapConnection {
ImapResponse response = responseParser.readResponse(callback);
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, getLogId() + "<<<" + response);
Timber.v("%s<<<%s", getLogId(), response);
}
return response;
@ -820,8 +819,8 @@ class ImapConnection {
if (responseTag.equalsIgnoreCase(tag)) {
throw new MessagingException("Command continuation aborted: " + response);
} else {
Log.w(LOG_TAG, "After sending tag " + tag + ", got tag response from previous command " +
response + " for " + getLogId());
Timber.w("After sending tag %s, got tag response from previous command %s for %s",
tag, response, getLogId());
}
}
} while (!response.isContinuationRequested());

View file

@ -17,7 +17,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.FetchProfile;
@ -34,8 +33,8 @@ import com.fsck.k9.mail.internet.MimeHeader;
import com.fsck.k9.mail.internet.MimeMessageHelper;
import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.store.imap.ImapUtility.getLastResponse;
@ -162,7 +161,7 @@ class ImapFolder extends Folder<ImapMessage> {
} catch (IOException ioe) {
throw ioExceptionHandler(connection, ioe);
} catch (MessagingException me) {
Log.e(LOG_TAG, "Unable to open connection for " + getLogId(), me);
Timber.e(me, "Unable to open connection for %s", getLogId());
throw me;
}
}
@ -211,7 +210,7 @@ class ImapFolder extends Folder<ImapMessage> {
synchronized (this) {
// If we are mid-search and we get a close request, we gotta trash the connection.
if (inSearch && connection != null) {
Log.i(LOG_TAG, "IMAP search was aborted, shutting down connection.");
Timber.i("IMAP search was aborted, shutting down connection.");
connection.close();
} else {
store.releaseConnection(connection);
@ -354,8 +353,8 @@ class ImapFolder extends Folder<ImapMessage> {
// operation fails. This will save a roundtrip if the folder already exists.
if (!exists(escapedDestinationFolderName)) {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "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);
@ -407,16 +406,16 @@ class ImapFolder extends Folder<ImapMessage> {
if (!exists(escapedTrashFolderName)) {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "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()) {
Log.d(LOG_TAG, "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);
@ -728,18 +727,17 @@ class ImapFolder extends Folder<ImapMessage> {
try {
msgSeqUidMap.put(msgSeq, uid);
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Stored uid '" + uid + "' for msgSeq " + msgSeq + " into map");
Timber.v("Stored uid '%s' for msgSeq %d into map", uid, msgSeq);
}
} catch (Exception e) {
Log.e(LOG_TAG, "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()) {
Log.d(LOG_TAG, "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);
@ -813,7 +811,7 @@ class ImapFolder extends Folder<ImapMessage> {
if (!message.getUid().equals(uid)) {
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Did not ask for UID " + uid + " for " + getLogId());
Timber.d("Did not ask for UID %s for %s", uid, getLogId());
}
handleUntaggedResponse(response);
@ -902,7 +900,7 @@ class ImapFolder extends Folder<ImapMessage> {
parseBodyStructure(bs, message, "TEXT");
} catch (MessagingException e) {
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Error handling message for " + getLogId(), e);
Timber.d(e, "Error handling message for %s", getLogId());
}
message.setBody(null);
}
@ -949,7 +947,7 @@ class ImapFolder extends Folder<ImapMessage> {
if ("UIDNEXT".equalsIgnoreCase(key)) {
uidNext = bracketed.getLong(1);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got UidNext = " + uidNext + " for " + getLogId());
Timber.d("Got UidNext = %s for %s", uidNext, getLogId());
}
}
}
@ -966,7 +964,7 @@ class ImapFolder extends Folder<ImapMessage> {
if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXISTS")) {
messageCount = response.getNumber(0);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged EXISTS with value " + messageCount + " for " + getLogId());
Timber.d("Got untagged EXISTS with value %d for %s", messageCount, getLogId());
}
}
@ -975,7 +973,7 @@ class ImapFolder extends Folder<ImapMessage> {
if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXPUNGE") && messageCount > 0) {
messageCount--;
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged EXPUNGE with messageCount " + messageCount + " for " + getLogId());
Timber.d("Got untagged EXPUNGE with messageCount %d for %s", messageCount, getLogId());
}
}
}
@ -1204,7 +1202,7 @@ class ImapFolder extends Folder<ImapMessage> {
*/
String newUid = getUidFromMessageId(message);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got UID " + newUid + " for message for " + getLogId());
Timber.d("Got UID %s for message for %s", newUid, getLogId());
}
if (!TextUtils.isEmpty(newUid)) {
@ -1235,14 +1233,14 @@ class ImapFolder extends Folder<ImapMessage> {
if (messageIdHeader.length == 0) {
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "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()) {
Log.d(LOG_TAG, "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));
@ -1323,7 +1321,7 @@ class ImapFolder extends Folder<ImapMessage> {
return null;
}
} catch (Exception e) {
Log.e(LOG_TAG, "Exception while updated push state for " + getLogId(), e);
Timber.e(e, "Exception while updated push state for %s", getLogId());
return null;
}
}
@ -1355,7 +1353,7 @@ class ImapFolder extends Folder<ImapMessage> {
}
private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) {
Log.e(LOG_TAG, "IOException for " + getLogId(), ioe);
Timber.e(ioe, "IOException for %s", getLogId());
if (connection != null) {
connection.close();

View file

@ -11,7 +11,6 @@ import java.util.List;
import android.content.Context;
import android.os.PowerManager;
import android.util.Log;
import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.Flag;
@ -22,8 +21,8 @@ import com.fsck.k9.mail.PushReceiver;
import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.store.RemoteStore;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.K9MailLib.PUSH_WAKE_LOCK_TIMEOUT;
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
@ -89,12 +88,12 @@ class ImapFolderPusher extends ImapFolder {
ImapConnection conn = connection;
if (conn != null) {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Closing connection to stop pushing for " + getLogId());
Timber.v("Closing connection to stop pushing for %s", getLogId());
}
conn.close();
} else {
Log.w(LOG_TAG, "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());
}
}
@ -106,7 +105,7 @@ class ImapFolderPusher extends ImapFolder {
equalsIgnoreCase(responseType, "EXISTS")) {
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Storing response " + response + " for later processing");
Timber.d("Storing response %s for later processing", response);
}
synchronized (storedUntaggedResponses) {
@ -133,7 +132,7 @@ class ImapFolderPusher extends ImapFolder {
wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT);
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Pusher starting for " + getLogId());
Timber.i("Pusher starting for %s", getLogId());
}
long lastUidNext = -1L;
@ -178,7 +177,7 @@ class ImapFolderPusher extends ImapFolder {
processStoredUntaggedResponses();
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "About to IDLE for " + getLogId());
Timber.i("About to IDLE for %s", getLogId());
}
prepareForIdle();
@ -193,7 +192,7 @@ class ImapFolderPusher extends ImapFolder {
reacquireWakeLockAndCleanUp();
if (K9MailLib.isDebug()) {
Log.e(K9MailLib.LOG_TAG, "Authentication failed. Stopping ImapFolderPusher.", e);
Timber.e(e, "Authentication failed. Stopping ImapFolderPusher.");
}
pushReceiver.authenticationFailed();
@ -202,10 +201,10 @@ class ImapFolderPusher extends ImapFolder {
reacquireWakeLockAndCleanUp();
if (stop) {
Log.i(LOG_TAG, "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);
Log.e(LOG_TAG, "Got exception while idling for " + getLogId(), e);
Timber.e("Got exception while idling for %s", getLogId());
pushReceiver.sleep(wakeLock, delayTime);
@ -216,8 +215,7 @@ class ImapFolderPusher extends ImapFolder {
idleFailureCount++;
if (idleFailureCount > IDLE_FAILURE_COUNT_LIMIT) {
Log.e(LOG_TAG, "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;
@ -230,12 +228,12 @@ class ImapFolderPusher extends ImapFolder {
try {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Pusher for " + getLogId() + " is exiting");
Timber.i("Pusher for %s is exiting", getLogId());
}
close();
} catch (Exception me) {
Log.e(LOG_TAG, "Got exception while closing for " + getLogId(), me);
Timber.e(me, "Got exception while closing for %s", getLogId());
} finally {
wakeLock.release();
}
@ -251,7 +249,7 @@ class ImapFolderPusher extends ImapFolder {
try {
connection.close();
} catch (Exception me) {
Log.e(LOG_TAG, "Got exception while closing for exception for " + getLogId(), me);
Timber.e(me, "Got exception while closing for exception for %s", getLogId());
}
connection = null;
@ -264,7 +262,7 @@ class ImapFolderPusher extends ImapFolder {
}
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "uidNext is -1, using search to find highest UID");
Timber.d("uidNext is -1, using search to find highest UID");
}
long highestUid = getHighestUid();
@ -275,7 +273,7 @@ class ImapFolderPusher extends ImapFolder {
newUidNext = highestUid + 1;
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "highest UID = " + highestUid + ", set newUidNext to " + newUidNext);
Timber.d("highest UID = %d, set newUidNext to %d", highestUid, newUidNext);
}
return newUidNext;
@ -365,12 +363,12 @@ class ImapFolderPusher extends ImapFolder {
@Override
public void handleAsyncUntaggedResponse(ImapResponse response) {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Got async response: " + response);
Timber.v("Got async response: %s", response);
}
if (stop) {
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "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();
@ -384,14 +382,14 @@ class ImapFolderPusher extends ImapFolder {
wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "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()) {
Log.d(LOG_TAG, "Idling " + getLogId());
Timber.d("Idling %s", getLogId());
}
idleStopper.startAcceptingDoneContinuation(connection);
@ -415,8 +413,8 @@ class ImapFolderPusher extends ImapFolder {
}
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "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);
@ -462,7 +460,7 @@ class ImapFolderPusher extends ImapFolder {
}
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "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()) {
@ -483,12 +481,12 @@ class ImapFolderPusher extends ImapFolder {
try {
Object responseType = response.get(1);
if (equalsIgnoreCase(responseType, "FETCH")) {
Log.i(LOG_TAG, "Got FETCH " + response);
Timber.i("Got FETCH %s", response);
long msgSeq = response.getLong(0);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged FETCH for msgseq " + msgSeq + " for " + getLogId());
Timber.d("Got untagged FETCH for msgseq %d for %s", msgSeq, getLogId());
}
if (!flagSyncMsgSeqs.contains(msgSeq)) {
@ -503,7 +501,7 @@ class ImapFolderPusher extends ImapFolder {
}
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged EXPUNGE for msgseq " + msgSeq + " for " + getLogId());
Timber.d("Got untagged EXPUNGE for msgseq %d for %s", msgSeq, getLogId());
}
List<Long> newSeqs = new ArrayList<Long>();
@ -525,15 +523,14 @@ class ImapFolderPusher extends ImapFolder {
for (long msgSeqNum : msgSeqs) {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Comparing EXPUNGEd msgSeq " + msgSeq + " to " + msgSeqNum);
Timber.v("Comparing EXPUNGEd msgSeq %d to %d", msgSeq, msgSeqNum);
}
if (msgSeqNum == msgSeq) {
String uid = msgSeqUidMap.get(msgSeqNum);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Scheduling removal of UID " + uid + " because msgSeq " + msgSeqNum +
" was expunged");
Timber.d("Scheduling removal of UID %s because msgSeq %d was expunged", uid, msgSeqNum);
}
removeMsgUids.add(uid);
@ -542,8 +539,7 @@ class ImapFolderPusher extends ImapFolder {
String uid = msgSeqUidMap.get(msgSeqNum);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Reducing msgSeq for UID " + uid + " from " + msgSeqNum + " to " +
(msgSeqNum - 1));
Timber.d("Reducing msgSeq for UID %s from %d to %d", uid, msgSeqNum, (msgSeqNum - 1));
}
msgSeqUidMap.remove(msgSeqNum);
@ -552,7 +548,7 @@ class ImapFolderPusher extends ImapFolder {
}
}
} catch (Exception e) {
Log.e(LOG_TAG, "Could not handle untagged FETCH for " + getLogId(), e);
Timber.e(e, "Could not handle untagged FETCH for %s", getLogId());
}
}
@ -568,7 +564,7 @@ class ImapFolderPusher extends ImapFolder {
long newUid = Long.parseLong(messageList.get(0).getUid());
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Got newUid " + newUid + " for message " + end + " on " + getLogId());
Timber.i("Got newUid %s for message %d on %s", newUid, end, getLogId());
}
long startUid = oldUidNext;
@ -582,7 +578,7 @@ class ImapFolderPusher extends ImapFolder {
if (newUid >= startUid) {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Needs sync from uid " + startUid + " to " + newUid + " for " + getLogId());
Timber.i("Needs sync from uid %d to %d for %s", startUid, newUid, getLogId());
}
List<Message> messages = new ArrayList<Message>();
@ -620,7 +616,7 @@ class ImapFolderPusher extends ImapFolder {
msgSeqUidMap.clear();
String existingUid = existingMessage.getUid();
Log.w(LOG_TAG, "Message with UID " + existingUid + " still exists on server, not expunging");
Timber.w("Message with UID %s still exists on server, not expunging", existingUid);
removeUids.remove(existingUid);
}
@ -631,7 +627,7 @@ class ImapFolderPusher extends ImapFolder {
try {
message.setFlagInternal(Flag.DELETED, true);
} catch (MessagingException me) {
Log.e(LOG_TAG, "Unable to set DELETED flag on message " + message.getUid());
Timber.e("Unable to set DELETED flag on message %s", message.getUid());
}
messages.add(message);
@ -639,7 +635,7 @@ class ImapFolderPusher extends ImapFolder {
pushReceiver.messagesRemoved(ImapFolderPusher.this, messages);
} catch (Exception e) {
Log.e(LOG_TAG, "Cannot remove EXPUNGEd messages", e);
Timber.e("Cannot remove EXPUNGEd messages");
}
}
@ -655,7 +651,7 @@ class ImapFolderPusher extends ImapFolder {
private void notifyMessagesArrived(long startUid, long uidNext) {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Needs sync from uid " + startUid + " to " + uidNext + " for " + getLogId());
Timber.i("Needs sync from uid %d to %d for %s", startUid, uidNext, getLogId());
}
int count = (int) (uidNext - startUid);
@ -677,10 +673,10 @@ class ImapFolderPusher extends ImapFolder {
oldUidNext = pushState.uidNext;
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Got oldUidNext " + oldUidNext + " for " + getLogId());
Timber.i("Got oldUidNext %d for %s", oldUidNext, getLogId());
}
} catch (Exception e) {
Log.e(LOG_TAG, "Unable to get oldUidNext for " + getLogId(), e);
Timber.e(e, "Unable to get oldUidNext for %s", getLogId());
}
return oldUidNext;

View file

@ -1,9 +1,7 @@
package com.fsck.k9.mail.store.imap;
import android.util.Log;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
class ImapPushState {
@ -25,7 +23,7 @@ class ImapPushState {
return new ImapPushState(newUidNext);
} catch (NumberFormatException e) {
Log.e(LOG_TAG, "Unable to part uidNext value " + value, e);
Timber.e(e, "Unable to part uidNext value %s", value);
}
return createDefaultImapPushState();

View file

@ -4,13 +4,10 @@ package com.fsck.k9.mail.store.imap;
import java.util.ArrayList;
import java.util.List;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.PushReceiver;
import com.fsck.k9.mail.Pusher;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
class ImapPusher implements Pusher {
@ -50,7 +47,7 @@ class ImapPusher implements Pusher {
try {
folderPusher.refresh();
} catch (Exception e) {
Log.e(LOG_TAG, "Got exception while refreshing for " + folderPusher.getName(), e);
Timber.e(e, "Got exception while refreshing for %s", folderPusher.getName());
}
}
}
@ -59,19 +56,19 @@ class ImapPusher implements Pusher {
@Override
public void stop() {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Requested stop of IMAP pusher");
Timber.i("Requested stop of IMAP pusher");
}
synchronized (folderPushers) {
for (ImapFolderPusher folderPusher : folderPushers) {
try {
if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Requesting stop of IMAP folderPusher " + folderPusher.getName());
Timber.i("Requesting stop of IMAP folderPusher %s", folderPusher.getName());
}
folderPusher.stop();
} catch (Exception e) {
Log.e(LOG_TAG, "Got exception while stopping " + folderPusher.getName(), e);
Timber.e(e, "Got exception while stopping %s", folderPusher.getName());
}
}

View file

@ -6,14 +6,12 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.filter.FixedLengthInputStream;
import com.fsck.k9.mail.filter.PeekableInputStream;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
class ImapResponseParser {
@ -88,12 +86,11 @@ class ImapResponseParser {
response = readResponse();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, logId + "<<<" + response);
Timber.v("%s<<<%s", logId, response);
}
if (response.getTag() != null && !response.getTag().equalsIgnoreCase(tag)) {
Log.w(LOG_TAG, "After sending tag " + tag + ", got tag response from previous command " + response +
" for " + logId);
Timber.w("After sending tag %s, got tag response from previous command %s for %s", tag, response, logId);
Iterator<ImapResponse> responseIterator = responses.iterator();

View file

@ -14,9 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import android.accounts.AccountManager;
import android.net.ConnectivityManager;
import android.util.Log;
import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity;
@ -31,8 +29,7 @@ import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.StoreConfig;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
/**
@ -183,8 +180,9 @@ public class ImapStore extends RemoteStore {
try {
decodedFolderName = folderNameCodec.decode(listResponse.getName());
} catch (CharacterCodingException e) {
Log.w(LOG_TAG, "Folder name not correctly encoded with the UTF-7 variant " +
"as defined by RFC 3501: " + listResponse.getName(), e);
Timber.w(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
// a folder name. Use the decoded name only for showing it to the user.
@ -239,13 +237,13 @@ public class ImapStore extends RemoteStore {
void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException {
if (!connection.hasCapability(Capabilities.SPECIAL_USE)) {
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "No detected folder auto-configuration methods.");
Timber.d("No detected folder auto-configuration methods.");
}
return;
}
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration: Using RFC6154/SPECIAL-USE.");
Timber.d("Folder auto-configuration: Using RFC6154/SPECIAL-USE.");
}
String command = String.format("LIST (SPECIAL-USE) \"\" %s", ImapUtility.encodeString(getCombinedPrefix() + "*"));
@ -258,8 +256,8 @@ public class ImapStore extends RemoteStore {
try {
decodedFolderName = folderNameCodec.decode(listResponse.getName());
} catch (CharacterCodingException e) {
Log.w(LOG_TAG, "Folder name not correctly encoded with the UTF-7 variant " +
"as defined by RFC 3501: " + listResponse.getName(), e);
Timber.w(e, "Folder name not correctly encoded with the UTF-7 variant as defined by RFC 3501: %s",
listResponse.getName());
// We currently just skip folders with malformed names.
continue;
}
@ -272,27 +270,27 @@ public class ImapStore extends RemoteStore {
if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) {
mStoreConfig.setArchiveFolderName(decodedFolderName);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Archive folder: " + decodedFolderName);
Timber.d("Folder auto-configuration detected Archive folder: %s", decodedFolderName);
}
} else if (listResponse.hasAttribute("\\Drafts")) {
mStoreConfig.setDraftsFolderName(decodedFolderName);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Drafts folder: " + decodedFolderName);
Timber.d("Folder auto-configuration detected Drafts folder: %s", decodedFolderName);
}
} else if (listResponse.hasAttribute("\\Sent")) {
mStoreConfig.setSentFolderName(decodedFolderName);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Sent folder: " + decodedFolderName);
Timber.d("Folder auto-configuration detected Sent folder: %s", decodedFolderName);
}
} else if (listResponse.hasAttribute("\\Junk")) {
mStoreConfig.setSpamFolderName(decodedFolderName);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Spam folder: " + decodedFolderName);
Timber.d("Folder auto-configuration detected Spam folder: %s", decodedFolderName);
}
} else if (listResponse.hasAttribute("\\Trash")) {
mStoreConfig.setTrashFolderName(decodedFolderName);
if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Trash folder: " + decodedFolderName);
Timber.d("Folder auto-configuration detected Trash folder: %s", decodedFolderName);
}
}
}

View file

@ -17,12 +17,11 @@
package com.fsck.k9.mail.store.imap;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
/**
* Utility methods for use with IMAP.
@ -101,12 +100,12 @@ class ImapUtility {
}
}
} else {
Log.d(LOG_TAG, "Invalid range: " + range);
Timber.d("Invalid range: %s", range);
}
}
}
} catch (NumberFormatException e) {
Log.d(LOG_TAG, "Invalid range value: " + range, e);
Timber.d(e, "Invalid range value: %s", range);
}
return list;
@ -122,7 +121,7 @@ class ImapUtility {
// do nothing
}
Log.d(LOG_TAG, "Invalid UID value: " + number);
Timber.d("Invalid UID value: %s", number);
return false;
}

View file

@ -2,20 +2,18 @@
package com.fsck.k9.mail.store.pop3;
import android.annotation.SuppressLint;
import android.util.Log;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.filter.Hex;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.MessageRetrievalListener;
import com.fsck.k9.mail.ServerSettings.Type;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.StoreConfig;
import javax.net.ssl.SSLException;
import timber.log.Timber;
import java.io.*;
import java.net.*;
@ -36,7 +34,6 @@ import java.util.Map;
import java.util.Set;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_POP3;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
@ -664,7 +661,7 @@ public class Pop3Store extends RemoteStore {
// response = "+OK msgNum msgUid"
String[] uidParts = response.split(" +");
if (uidParts.length < 3 || !"+OK".equals(uidParts[0])) {
Log.e(LOG_TAG, "ERR response: " + response);
Timber.e("ERR response: %s", response);
return;
}
String msgUid = uidParts[2];
@ -723,7 +720,7 @@ public class Pop3Store extends RemoteStore {
for (String uid : uids) {
if (mUidToMsgMap.get(uid) == null) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "Need to index UID " + uid);
Timber.d("Need to index UID %s", uid);
}
unindexedUids.add(uid);
}
@ -749,7 +746,7 @@ public class Pop3Store extends RemoteStore {
String msgUid = uidParts[1];
if (unindexedUids.contains(msgUid)) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "Got msgNum " + msgNum + " for UID " + msgUid);
Timber.d("Got msgNum %d for UID %s", msgNum, msgUid);
}
Pop3Message message = mUidToMsgMap.get(msgUid);
@ -764,7 +761,7 @@ public class Pop3Store extends RemoteStore {
private void indexMessage(int msgNum, Pop3Message message) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "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);
mUidToMsgMap.put(message.getUid(), message);
@ -917,7 +914,7 @@ public class Pop3Store extends RemoteStore {
if (lines != -1 && (!mTopNotSupported || mCapabilities.top)) {
try {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3 && !mCapabilities.top) {
Log.d(LOG_TAG, "This server doesn't support the CAPA command. " +
Timber.d("This server doesn't support the CAPA command. " +
"Checking to see if the TOP command is supported nevertheless.");
}
@ -932,7 +929,7 @@ public class Pop3Store extends RemoteStore {
throw e;
} else {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "The server really doesn't support the TOP " +
Timber.d("The server really doesn't support the TOP " +
"command. Using RETR instead.");
}
@ -1040,7 +1037,7 @@ public class Pop3Store extends RemoteStore {
} while ((d = mIn.read()) != -1);
String ret = sb.toString();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "<<< " + ret);
Timber.d("<<< %s", ret);
}
return ret;
}
@ -1134,10 +1131,9 @@ public class Pop3Store extends RemoteStore {
if (command != null) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
if (sensitive && !K9MailLib.isDebugSensitive()) {
Log.d(LOG_TAG, ">>> "
+ "[Command Hidden, Enable Sensitive Debug Logging To Show]");
Timber.d(">>> [Command Hidden, Enable Sensitive Debug Logging To Show]");
} else {
Log.d(LOG_TAG, ">>> " + command);
Timber.d(">>> %s", command);
}
}

View file

@ -1,7 +1,5 @@
package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -11,7 +9,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import timber.log.Timber;
/**
* Maintains WebDAV data
@ -189,7 +187,7 @@ class DataSet {
Date parsedDate = dfInput.parse(date);
tempDate = dfOutput.format(parsedDate);
} catch (java.text.ParseException pe) {
Log.e(LOG_TAG, "Error parsing date: " + pe + "\nTrace: " + WebDavUtils.processException(pe));
Timber.e(pe, "Error parsing date: %s", date);
}
envelope.addHeader(header, tempDate);
} else {

View file

@ -1,15 +1,13 @@
package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import timber.log.Timber;
import java.net.URI;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
@ -36,9 +34,7 @@ public class HttpGeneric extends HttpEntityEnclosingRequestBase {
public HttpGeneric(final String uri) {
super();
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Starting uri = '" + uri + "'");
}
Timber.v("Starting uri = '%s'", uri);
String[] urlParts = uri.split("/");
int length = urlParts.length;
@ -55,8 +51,7 @@ public class HttpGeneric extends HttpEntityEnclosingRequestBase {
end = end.replaceAll("\\+", "%20");
}
} catch (IllegalArgumentException iae) {
Log.e(LOG_TAG, "IllegalArgumentException caught in HttpGeneric(String uri): " + iae + "\nTrace: "
+ WebDavUtils.processException(iae));
Timber.e(iae, "IllegalArgumentException caught in HttpGeneric(String uri): %s", end);
}
for (int i = 0; i < length - 1; i++) {
@ -67,12 +62,11 @@ public class HttpGeneric extends HttpEntityEnclosingRequestBase {
}
}
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Log.v(LOG_TAG, "url = '" + url + "' length = " + url.length()
+ ", end = '" + end + "' length = " + end.length());
Timber.v("url = '%s' length = %s, end = '%s' length = %s", url, url.length(), end, end.length());
}
url = url + "/" + end;
Log.i(LOG_TAG, "url = " + url);
Timber.d("url = %s", url);
setURI(URI.create(url));
}

View file

@ -1,7 +1,5 @@
package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import com.fsck.k9.mail.FetchProfile;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
@ -16,6 +14,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.StringEntity;
import timber.log.Timber;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
@ -35,7 +34,6 @@ import java.util.Map;
import java.util.Set;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
/**
@ -137,7 +135,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
headers.put("Brief", "t");
headers.put("If-Match", "*");
String action = (isMove ? "BMOVE" : "BCOPY");
Log.i(LOG_TAG, "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);
}
@ -161,7 +159,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
messageCount = dataset.getMessageCount();
}
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Log.v(LOG_TAG, "Counted messages and webdav returned: " + messageCount);
Timber.v("Counted messages and webdav returned: %d", messageCount);
}
return messageCount;
@ -354,16 +352,14 @@ class WebDavFolder extends Folder<WebDavMessage> {
*/
if (wdMessage.getUrl().equals("")) {
wdMessage.setUrl(getMessageUrls(new String[]{wdMessage.getUid()}).get(wdMessage.getUid()));
Log.i(LOG_TAG, "Fetching messages with UID = '" + wdMessage.getUid() + "', URL = '"
+ wdMessage.getUrl() + "'");
Timber.i("Fetching messages with UID = '%s', URL = '%s'", wdMessage.getUid(), wdMessage.getUrl());
if (wdMessage.getUrl().equals("")) {
throw new MessagingException("Unable to get URL for message");
}
}
try {
Log.i(LOG_TAG, "Fetching message with UID = '" + wdMessage.getUid() + "', URL = '"
+ wdMessage.getUrl() + "'");
Timber.i("Fetching message with UID = '%s', URL = '%s'", wdMessage.getUid(), wdMessage.getUrl());
HttpGet httpget = new HttpGet(new URI(wdMessage.getUrl()));
HttpResponse response;
HttpEntity entity;
@ -415,27 +411,25 @@ class WebDavFolder extends Folder<WebDavMessage> {
wdMessage.parse(istream);
} catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe.getMessage() + "\nTrace: "
+ WebDavUtils.processException(ioe));
Timber.e(ioe, "IOException during message parsing");
throw new MessagingException("I/O Error", ioe);
} finally {
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(istream);
}
} else {
Log.v(LOG_TAG, "Empty response");
Timber.v("Empty response");
}
} catch (IllegalArgumentException iae) {
Log.e(LOG_TAG, "IllegalArgumentException caught " + iae + "\nTrace: " + WebDavUtils.processException(iae));
Timber.e(iae, "IllegalArgumentException caught");
throw new MessagingException("IllegalArgumentException caught", iae);
} catch (URISyntaxException use) {
Log.e(LOG_TAG, "URISyntaxException caught " + use + "\nTrace: " + WebDavUtils.processException(use));
Timber.e(use, "URISyntaxException caught");
throw new MessagingException("URISyntaxException caught", use);
} catch (IOException ioe) {
Log.e(LOG_TAG, "Non-success response code loading message, response code was " + statusCode
+ "\nURL: " + wdMessage.getUrl() + "\nError: " + ioe.getMessage() + "\nTrace: "
+ WebDavUtils.processException(ioe));
Timber.e(ioe, "Non-success response code loading message, response code was %d, URL: %s",
statusCode, wdMessage.getUrl());
throw new MessagingException("Failure code " + statusCode, ioe);
}
@ -500,7 +494,8 @@ class WebDavFolder extends Folder<WebDavMessage> {
try {
wdMessage.setFlagInternal(Flag.SEEN, uidToReadStatus.get(wdMessage.getUid()));
} catch (NullPointerException e) {
Log.v(LOG_TAG, "Under some weird circumstances, setting the read status when syncing from webdav threw an NPE. Skipping.");
Timber.v(e, "Under some weird circumstances, " +
"setting the read status when syncing from webdav threw an NPE. Skipping.");
}
}
@ -562,7 +557,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
message.setNewHeaders(envelope);
message.setFlagInternal(Flag.SEEN, envelope.getReadStatus());
} else {
Log.e(LOG_TAG, "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) {
@ -676,7 +671,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
}
messageURL += encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml");
Log.i(LOG_TAG, "Uploading message as " + messageURL);
Timber.i("Uploading message as %s", messageURL);
store.sendRequest(messageURL, "PUT", bodyEntity, null, true);
@ -701,16 +696,14 @@ class WebDavFolder extends Folder<WebDavMessage> {
@Override
public String getUidFromMessageId(Message message) throws MessagingException {
Log.e(LOG_TAG,
"Unimplemented method getUidFromMessageId in WebDavStore.WebDavFolder could lead to duplicate messages "
Timber.e("Unimplemented method getUidFromMessageId in WebDavStore.WebDavFolder could lead to duplicate messages "
+ " being uploaded to the Sent folder");
return null;
}
@Override
public void setFlags(final Set<Flag> flags, boolean value) throws MessagingException {
Log.e(LOG_TAG,
"Unimplemented method setFlags(Set<Flag>, boolean) breaks markAllMessagesAsRead and EmptyTrash");
Timber.e("Unimplemented method setFlags(Set<Flag>, boolean) breaks markAllMessagesAsRead and EmptyTrash");
// Try to make this efficient by not retrieving all of the messages
}

View file

@ -1,7 +1,5 @@
package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpRequest;
@ -9,13 +7,12 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HttpContext;
import timber.log.Timber;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
/**
* HTTP client for WebDAV communication
*/
@ -41,7 +38,7 @@ public class WebDavHttpClient extends DefaultHttpClient {
}
public static void modifyRequestToAcceptGzipResponse(HttpRequest request) {
Log.i(LOG_TAG, "Requesting gzipped data");
Timber.i("Requesting gzipped data");
request.addHeader("Accept-Encoding", "gzip");
}
@ -57,7 +54,7 @@ public class WebDavHttpClient extends DefaultHttpClient {
if (contentEncoding == null)
return responseStream;
if (contentEncoding.contains("gzip")) {
Log.i(LOG_TAG, "Response is gzipped");
Timber.i("Response is gzipped");
responseStream = new GZIPInputStream(responseStream);
}
return responseStream;

View file

@ -1,17 +1,15 @@
package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeMessage;
import timber.log.Timber;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
@ -52,8 +50,7 @@ class WebDavMessage extends MimeMessage {
end = encodeUtf8(end);
end = end.replaceAll("\\+", "%20");
} catch (IllegalArgumentException iae) {
Log.e(LOG_TAG, "IllegalArgumentException caught in setUrl: " + iae + "\nTrace: "
+ WebDavUtils.processException(iae));
Timber.e(iae, "IllegalArgumentException caught in setUrl: ");
}
for (int i = 0; i < length - 1; i++) {
@ -101,7 +98,7 @@ class WebDavMessage extends MimeMessage {
@Override
public void delete(String trashFolderName) throws MessagingException {
WebDavFolder wdFolder = (WebDavFolder) getFolder();
Log.i(LOG_TAG, "Deleting message by moving to " + trashFolderName);
Timber.i("Deleting message by moving to %s", trashFolderName);
wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore().getFolder(trashFolderName));
}

View file

@ -16,8 +16,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import android.util.Log;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.Folder;
@ -48,9 +46,9 @@ import org.apache.http.protocol.HttpContext;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
@ -525,7 +523,7 @@ public class WebDavStore extends RemoteStore {
performFormBasedAuthentication(null);
}
} catch (IOException ioe) {
Log.e(LOG_TAG, "Error during authentication: " + ioe + "\nStack: " + WebDavUtils.processException(ioe));
Timber.e(ioe, "Error during authentication");
throw new MessagingException("Error during authentication", ioe);
}
@ -589,7 +587,7 @@ public class WebDavStore extends RemoteStore {
} catch (SSLException e) {
throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + WebDavUtils.processException(ioe));
Timber.e(ioe, "IOException during initial connection");
throw new MessagingException("IOException", ioe);
}
@ -688,7 +686,7 @@ public class WebDavStore extends RemoteStore {
response = httpClient.executeOverride(request, httpContext);
authenticated = testAuthenticationResponse(response);
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "URISyntaxException caught " + e + "\nTrace: " + WebDavUtils.processException(e));
Timber.e(e, "URISyntaxException caught");
throw new MessagingException("URISyntaxException caught", e);
}
} else {
@ -778,7 +776,7 @@ public class WebDavStore extends RemoteStore {
}
}
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "URISyntaxException caught " + e + "\nTrace: " + WebDavUtils.processException(e));
Timber.e(e, "URISyntaxException");
throw new MessagingException("URISyntaxException caught", e);
}
}
@ -815,11 +813,11 @@ public class WebDavStore extends RemoteStore {
Scheme s = new Scheme("https", new WebDavSocketFactory(hostname, 443), 443);
reg.register(s);
} catch (NoSuchAlgorithmException nsa) {
Log.e(LOG_TAG, "NoSuchAlgorithmException in getHttpClient: " + nsa);
throw new MessagingException("NoSuchAlgorithmException in getHttpClient: " + nsa);
Timber.e(nsa, "NoSuchAlgorithmException in getHttpClient");
throw new MessagingException("NoSuchAlgorithmException in getHttpClient: ", nsa);
} catch (KeyManagementException kme) {
Log.e(LOG_TAG, "KeyManagementException in getHttpClient: " + kme);
throw new MessagingException("KeyManagementException in getHttpClient: " + kme);
Timber.e(kme, "KeyManagementException in getHttpClient");
throw new MessagingException("KeyManagementException in getHttpClient: ", kme);
}
}
return httpClient;
@ -885,10 +883,10 @@ public class WebDavStore extends RemoteStore {
return WebDavHttpClient.getUngzippedContent(entity);
}
} catch (UnsupportedEncodingException uee) {
Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + WebDavUtils.processException(uee));
Timber.e(uee, "UnsupportedEncodingException: ");
throw new MessagingException("UnsupportedEncodingException", uee);
} catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + WebDavUtils.processException(ioe));
Timber.e(ioe, "IOException: ");
throw new MessagingException("IOException", ioe);
}
@ -926,8 +924,7 @@ public class WebDavStore extends RemoteStore {
throws MessagingException {
DataSet dataset = new DataSet();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Log.v(LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '"
+ messageBody + "'");
Timber.v("processRequest url = '%s', method = '%s', messageBody = '%s'", url, method, messageBody);
}
if (url == null ||
@ -959,22 +956,20 @@ public class WebDavStore extends RemoteStore {
dataset = myHandler.getDataSet();
} catch (SAXException se) {
Log.e(LOG_TAG,
"SAXException in processRequest() " + se + "\nTrace: " + WebDavUtils.processException(se));
Timber.e(se, "SAXException in processRequest()");
throw new MessagingException("SAXException in processRequest() ", se);
} catch (ParserConfigurationException pce) {
Log.e(LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: "
+ WebDavUtils.processException(pce));
Timber.e(pce, "ParserConfigurationException in processRequest()");
throw new MessagingException("ParserConfigurationException in processRequest() ", pce);
}
istream.close();
}
} catch (UnsupportedEncodingException uee) {
Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + WebDavUtils.processException(uee));
Timber.e(uee, "UnsupportedEncodingException: ");
throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee);
} catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + WebDavUtils.processException(ioe));
Timber.e(ioe, "IOException: ");
throw new MessagingException("IOException in processRequest() ", ioe);
}

View file

@ -4,12 +4,9 @@ import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.ServerSettings;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
/**
* This class is used to store the decoded contents of an WebDavStore URI.

View file

@ -1,23 +0,0 @@
package com.fsck.k9.mail.store.webdav;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/**
* Utility methods for WebDAV code.
*/
class WebDavUtils {
/**
* Returns a string of the stacktrace for a Throwable to allow for easy inline printing of errors.
*/
static String processException(Throwable t) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
t.printStackTrace(ps);
ps.close();
return baos.toString();
}
}

View file

@ -1,8 +1,6 @@
package com.fsck.k9.mail.transport;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
@ -11,11 +9,10 @@ import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.store.StoreConfig;
import com.fsck.k9.mail.store.webdav.WebDavHttpClient;
import com.fsck.k9.mail.store.webdav.WebDavStore;
import timber.log.Timber;
import java.util.Collections;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class WebDavTransport extends Transport {
/**
@ -49,13 +46,13 @@ public class WebDavTransport extends Transport {
store = new WebDavStore(storeConfig, new WebDavHttpClient.WebDavHttpClientFactory());
if (K9MailLib.isDebug())
Log.d(LOG_TAG, ">>> New WebDavTransport creation complete");
Timber.d(">>> New WebDavTransport creation complete");
}
@Override
public void open() throws MessagingException {
if (K9MailLib.isDebug())
Log.d(LOG_TAG, ">>> open called on WebDavTransport ");
Timber.d( ">>> open called on WebDavTransport ");
store.getHttpClient();
}

View file

@ -24,7 +24,6 @@ import java.util.Map;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.AuthType;
@ -50,10 +49,10 @@ import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.StoreConfig;
import javax.net.ssl.SSLException;
import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_SMTP;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class SmtpTransport extends Transport {
public static final int SMTP_CONTINUE_REQUEST = 334;
@ -463,7 +462,7 @@ public class SmtpTransport extends Transport {
mLargestAcceptableMessage = Integer.parseInt(optionalsizeValue);
} catch (NumberFormatException e) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) {
Log.d(LOG_TAG, "Tried to parse " + optionalsizeValue + " and get an int", e);
Timber.d(e, "Tried to parse %s and get an int", optionalsizeValue);
}
}
}
@ -502,13 +501,13 @@ public class SmtpTransport extends Transport {
}
} catch (NegativeSmtpReplyException e) {
if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Server doesn't support the EHLO command. Trying HELO...");
Timber.v("Server doesn't support the EHLO command. Trying HELO...");
}
try {
executeCommand("HELO %s", host);
} catch (NegativeSmtpReplyException e2) {
Log.w(LOG_TAG, "Server doesn't support the HELO command. Continuing anyway.");
Timber.w("Server doesn't support the HELO command. Continuing anyway.");
}
}
return extensions;
@ -552,7 +551,7 @@ public class SmtpTransport extends Transport {
open();
if (!m8bitEncodingAllowed) {
Log.d(LOG_TAG, "Server does not support 8bit transfer encoding");
Timber.d("Server does not support 8bit transfer encoding");
}
// If the message has attachments and our server has told us about a limit on
// the size of messages, count the message's size before sending it
@ -628,7 +627,7 @@ public class SmtpTransport extends Transport {
}
String ret = sb.toString();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP)
Log.d(LOG_TAG, "SMTP <<< " + ret);
Timber.d("SMTP <<< %s", ret);
return ret;
}
@ -641,7 +640,7 @@ public class SmtpTransport extends Transport {
} else {
commandToLog = "SMTP >>> " + s;
}
Log.d(LOG_TAG, commandToLog);
Timber.d(commandToLog);
}
byte[] data = s.concat("\r\n").getBytes();
@ -860,7 +859,7 @@ public class SmtpTransport extends Transport {
//if a token was invalid before use (e.g. due to expiry). But we don't
//This is the intended behaviour per AccountManager
Log.v(LOG_TAG, "Authentication exception, re-trying with new token", negativeResponseFromOldToken);
Timber.v(negativeResponseFromOldToken, "Authentication exception, re-trying with new token");
try {
attemptXoauth2(username);
} catch (NegativeSmtpReplyException negativeResponseFromNewToken) {
@ -870,8 +869,7 @@ public class SmtpTransport extends Transport {
//Okay, we failed on a new token.
//Invalidate the token anyway but assume it's permanent.
Log.v(LOG_TAG, "Authentication exception for new token, permanent error assumed",
negativeResponseFromNewToken);
Timber.v(negativeResponseFromNewToken, "Authentication exception for new token, permanent error assumed");
oauthTokenProvider.invalidateToken(username);

View file

@ -3,7 +3,6 @@ package com.fsck.k9.mail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

View file

@ -27,7 +27,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

View file

@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class ImapListTest {

View file

@ -38,7 +38,6 @@ import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;

View file

@ -44,7 +44,6 @@ import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.OngoingStubbing;
import org.robolectric.annotation.Config;
import static junit.framework.Assert.assertSame;
import static org.junit.Assert.assertEquals;

View file

@ -34,7 +34,7 @@ dependencies {
compile 'de.cketti.safecontentresolver:safe-content-resolver-v14:0.9.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
compile 'com.squareup.moshi:moshi:1.2.0'
compile 'com.jakewharton.timber:timber:4.5.1'
compile "com.jakewharton.timber:timber:${timberVersion}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'