Unify LogTag

There is now only one LogTag class. The static initializer of
GmailApplication (existing), EmailApplication (new), and
Exchange (existing)  will now set the log tag to "Gmail" and "Email",
respectively. Up until that code is run, it will be "UnifiedEmail".

"setprop log.tag.Gmail VERBOSE" (or .Email, .Exchange) will trigger
all logs to be printed as long as they go through LogUtils,
regardless of what tag is used by that individual log. This lets us
still turn on logging everywhere in one command, but also lets us use
more descriptive tags (like the class name).

And since we no longer have three com.android.mail.utils.LogTag
classes, builds will be much easier.

Also, we now use LogUtils everywhere.

Change-Id: Ib565414fae51d0c3367370db9717aece45f7eb36
diff --git a/src/com/android/exchange/CalendarSyncEnabler.java b/src/com/android/exchange/CalendarSyncEnabler.java
index 1def23d..ce2f327 100644
--- a/src/com/android/exchange/CalendarSyncEnabler.java
+++ b/src/com/android/exchange/CalendarSyncEnabler.java
@@ -17,6 +17,7 @@
 package com.android.exchange;
 
 import com.android.emailcommon.Logging;
+import com.android.mail.utils.LogUtils;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
@@ -28,7 +29,6 @@
 import android.content.Intent;
 import android.net.Uri;
 import android.provider.CalendarContract;
-import android.util.Log;
 
 /**
  * Utility class to enable Exchange calendar sync for all existing Exchange accounts.
@@ -70,7 +70,7 @@
                 .getAccountsByType(Eas.EXCHANGE_ACCOUNT_MANAGER_TYPE);
         for (Account account : exchangeAccounts) {
             final String emailAddress = account.name;
-            Log.i(Logging.LOG_TAG, "Enabling Exchange calendar sync for " + emailAddress);
+            LogUtils.i(Logging.LOG_TAG, "Enabling Exchange calendar sync for " + emailAddress);
 
             ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 1);
             ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY, true);
diff --git a/src/com/android/exchange/Eas.java b/src/com/android/exchange/Eas.java
index 6fa51cc..4a5fc94 100644
--- a/src/com/android/exchange/Eas.java
+++ b/src/com/android/exchange/Eas.java
@@ -17,10 +17,9 @@
 
 package com.android.exchange;
 
-import android.util.Log;
-
 import com.android.emailcommon.service.EmailServiceProxy;
 import com.android.emailcommon.service.SyncWindow;
+import com.android.mail.utils.LogUtils;
 
 /**
  * Constants used throughout the EAS implementation are stored here.
@@ -105,7 +104,7 @@
             if (FILE_LOG || PARSER_LOG) {
                 USER_LOG = true;
             }
-            Log.d("Eas Debug", "Logging: " + (USER_LOG ? "User " : "") +
+            LogUtils.d("Eas Debug", "Logging: " + (USER_LOG ? "User " : "") +
                     (PARSER_LOG ? "Parser " : "") + (FILE_LOG ? "File" : ""));
         }
     }
diff --git a/src/com/android/exchange/EasAccountService.java b/src/com/android/exchange/EasAccountService.java
index c8eb658..87d906d 100644
--- a/src/com/android/exchange/EasAccountService.java
+++ b/src/com/android/exchange/EasAccountService.java
@@ -28,7 +28,6 @@
 import android.provider.ContactsContract;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
-import android.util.Log;
 
 import com.android.emailcommon.TrafficFlags;
 import com.android.emailcommon.mail.MessagingException;
@@ -51,6 +50,7 @@
 import com.android.exchange.adapter.PingParser;
 import com.android.exchange.adapter.Serializer;
 import com.android.exchange.adapter.Tags;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import org.apache.http.Header;
@@ -190,7 +190,7 @@
                 ExchangeService.kick("sync finished");
             }
         } catch (ProviderUnavailableException e) {
-            Log.e(TAG, "EmailProvider unavailable; sync ended prematurely");
+            LogUtils.e(TAG, "EmailProvider unavailable; sync ended prematurely");
         }
     }
 
@@ -512,7 +512,7 @@
      * @param message
      * @return whether this message is likely associated with a NAT failure
      */
-    private boolean isLikelyNatFailure(String message) {
+    private static boolean isLikelyNatFailure(String message) {
         if (message == null) return false;
         if (message.contains("reset by peer")) {
             return true;
@@ -887,7 +887,7 @@
      * @param exitStatus the service's exit status
      * @return the corresponding service status
      */
-    private int exitStatusToServiceStatus(int exitStatus) {
+    private static int exitStatusToServiceStatus(int exitStatus) {
         switch(exitStatus) {
             case EasSyncService.EXIT_SECURITY_FAILURE:
                 return EmailServiceStatus.SECURITY_FAILURE;
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index e729809..fb213f5 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -33,7 +33,6 @@
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.util.Base64;
-import android.util.Log;
 import android.util.Xml;
 
 import com.android.emailcommon.TrafficFlags;
@@ -77,6 +76,7 @@
 import com.android.exchange.adapter.Tags;
 import com.android.exchange.provider.GalResult;
 import com.android.exchange.utility.CalendarUtilities;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import org.apache.http.Header;
@@ -340,13 +340,13 @@
         // If we don't support any of the servers supported versions, throw an exception here
         // This will cause validation to fail
         if (ourVersion == null) {
-            Log.w(TAG, "No supported EAS versions: " + supportedVersions);
+            LogUtils.w(TAG, "No supported EAS versions: " + supportedVersions);
             throw new MessagingException(MessagingException.PROTOCOL_VERSION_UNSUPPORTED);
         } else {
             // Debug code for testing EAS 14.0; disables support for EAS 14.1
             // "adb shell setprop log.tag.Exchange14 VERBOSE"
             if (ourVersion.equals(Eas.SUPPORTED_PROTOCOL_EX2010_SP1) &&
-                    Log.isLoggable("Exchange14", Log.VERBOSE)) {
+                    LogUtils.isLoggable("Exchange14", LogUtils.VERBOSE)) {
                 ourVersion = Eas.SUPPORTED_PROTOCOL_EX2010;
             }
             service.mProtocolVersion = ourVersion;
@@ -599,7 +599,7 @@
      * @param post the HttpPost that was originally sent to the server
      * @return the HttpPost, updated with the redirect location
      */
-    private HttpPost getRedirect(HttpResponse resp, HttpPost post) {
+    private static HttpPost getRedirect(HttpResponse resp, HttpPost post) {
         Header locHeader = resp.getFirstHeader("X-MS-Location");
         if (locHeader != null) {
             String loc = locHeader.getValue();
@@ -862,7 +862,7 @@
                 if (name.equals("Error")) {
                     // Should parse the error
                 } else if (name.equals("Redirect")) {
-                    Log.d(TAG, "Redirect: " + parser.nextText());
+                    LogUtils.d(TAG, "Redirect: " + parser.nextText());
                 } else if (name.equals("Settings")) {
                     parseSettings(parser, hostAuth);
                 }
@@ -1275,7 +1275,7 @@
         synchronized(getSynchronizer()) {
             hasWakeLock = ExchangeService.isHoldingWakeLock(mMailboxId);
             if (isPingCommand && !hasWakeLock) {
-                Log.e(TAG, "executePostWithTimeout (ping) without holding wakelock");
+                LogUtils.e(TAG, "executePostWithTimeout (ping) without holding wakelock");
             }
             mPendingPost = method;
             long alarmTime = timeout + WATCHDOG_TIMEOUT_ALLOWANCE;
@@ -1679,7 +1679,7 @@
             // Send our changes up to the server
             if (mUpsyncFailed) {
                 if (Eas.USER_LOG) {
-                    Log.d(TAG, "Inhibiting upsync this cycle");
+                    LogUtils.d(TAG, "Inhibiting upsync this cycle");
                 }
             } else {
                 target.sendLocalChanges(s);
@@ -1965,7 +1965,7 @@
                 ExchangeService.kick("sync finished");
             }
         } catch (ProviderUnavailableException e) {
-            Log.e(TAG, "EmailProvider unavailable; sync ended prematurely");
+            LogUtils.e(TAG, "EmailProvider unavailable; sync ended prematurely");
         }
     }
 }
diff --git a/src/com/android/exchange/Exchange.java b/src/com/android/exchange/Exchange.java
index 496e1f5..faf2e43 100644
--- a/src/com/android/exchange/Exchange.java
+++ b/src/com/android/exchange/Exchange.java
@@ -18,6 +18,12 @@
 
 import android.app.Application;
 
+import com.android.mail.utils.LogTag;
+
 public class Exchange extends Application {
-    // TODO Investigate whether this class is needed
+    private static final String LOG_TAG = "Exchange";
+
+    static {
+        LogTag.setLogTag(LOG_TAG);
+    }
 }
diff --git a/src/com/android/exchange/ExchangeService.java b/src/com/android/exchange/ExchangeService.java
index f149c9f..1d5687b 100644
--- a/src/com/android/exchange/ExchangeService.java
+++ b/src/com/android/exchange/ExchangeService.java
@@ -32,7 +32,6 @@
 import android.os.RemoteException;
 import android.provider.CalendarContract.Calendars;
 import android.provider.CalendarContract.Events;
-import android.util.Log;
 
 import com.android.emailcommon.Api;
 import com.android.emailcommon.provider.Account;
@@ -59,6 +58,7 @@
 import com.android.exchange.adapter.Search;
 import com.android.exchange.utility.FileLogger;
 import com.android.mail.providers.UIProvider.AccountCapabilities;
+import com.android.mail.utils.LogUtils;
 
 import java.io.IOException;
 import java.util.concurrent.ConcurrentHashMap;
@@ -427,7 +427,7 @@
         return (account.mFlags & Account.FLAGS_SECURITY_HOLD) != 0;
     }
 
-    private boolean onSyncDisabledHold(Account account) {
+    private static boolean onSyncDisabledHold(Account account) {
         return (account.mFlags & Account.FLAGS_SYNC_DISABLED) != 0;
     }
 
@@ -551,7 +551,7 @@
                                 c.close();
                             }
                         } catch (ProviderUnavailableException e) {
-                            Log.w(TAG, "Observer failed; provider unavailable");
+                            LogUtils.w(TAG, "Observer failed; provider unavailable");
                         }
                     }}, "Calendar Observer").start();
             }
@@ -574,7 +574,7 @@
 
     public static void log(String tag, String str) {
         if (Eas.USER_LOG) {
-            Log.d(tag, str);
+            LogUtils.d(tag, str);
             if (Eas.FILE_LOG) {
                 FileLogger.log(tag, str);
             }
@@ -583,7 +583,7 @@
 
     public static void alwaysLog(String str) {
         if (!Eas.USER_LOG) {
-            Log.d(TAG, str);
+            LogUtils.d(TAG, str);
         } else {
             log(str);
         }
@@ -714,7 +714,7 @@
                 Account acct = Account.restoreAccountWithId(getContext(), acctId);
                 if (acct == null) {
                     // This account is in a bad state; don't create the mailbox.
-                    Log.e(TAG, "Cannot initialize bad acctId: " + acctId);
+                    LogUtils.e(TAG, "Cannot initialize bad acctId: " + acctId);
                     return;
                 }
                 Mailbox main = new Mailbox();
diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
index 09e2977..236a063 100644
--- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java
+++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
@@ -42,7 +42,6 @@
 import android.provider.ContactsContract.RawContacts;
 import android.provider.SyncStateContract;
 import android.text.TextUtils;
-import android.util.Log;
 
 import com.android.calendarcommon2.DateException;
 import com.android.calendarcommon2.Duration;
@@ -332,7 +331,7 @@
                     adapter.mAccountManagerAccount, adapter.mCalendarId);
         }
 
-        private void addOrganizerToAttendees(CalendarOperations ops, long eventId,
+        private static void addOrganizerToAttendees(CalendarOperations ops, long eventId,
                 String organizerName, String organizerEmail) {
             // Handle the organizer (who IS an attendee on device, but NOT in EAS)
             if (organizerName != null || organizerEmail != null) {
@@ -973,7 +972,7 @@
             }
         }
 
-        private int encodeVisibility(int easVisibility) {
+        private static int encodeVisibility(int easVisibility) {
             int visibility = 0;
             switch(easVisibility) {
                 case 0:
@@ -1484,7 +1483,7 @@
         }
     }
 
-    private String decodeVisibility(int visibility) {
+    private static String decodeVisibility(int visibility) {
         int easVisibility = 0;
         switch(visibility) {
             case Events.ACCESS_DEFAULT:
@@ -1503,7 +1502,7 @@
         return Integer.toString(easVisibility);
     }
 
-    private int getInt(ContentValues cv, String column) {
+    private static int getInt(ContentValues cv, String column) {
         Integer i = cv.getAsInteger(column);
         if (i == null) return 0;
         return i;
@@ -2177,7 +2176,7 @@
                 eventIterator.close();
             }
         } catch (RemoteException e) {
-            Log.e(TAG, "Could not read dirty events.");
+            LogUtils.e(TAG, "Could not read dirty events.");
         }
 
         return false;
diff --git a/src/com/android/exchange/adapter/ContactsSyncAdapter.java b/src/com/android/exchange/adapter/ContactsSyncAdapter.java
index c9ae7b9..dc7f997 100644
--- a/src/com/android/exchange/adapter/ContactsSyncAdapter.java
+++ b/src/com/android/exchange/adapter/ContactsSyncAdapter.java
@@ -57,7 +57,6 @@
 import android.text.util.Rfc822Token;
 import android.text.util.Rfc822Tokenizer;
 import android.util.Base64;
-import android.util.Log;
 
 import com.android.emailcommon.provider.Account;
 import com.android.emailcommon.provider.Mailbox;
@@ -66,6 +65,7 @@
 import com.android.exchange.Eas;
 import com.android.exchange.EasSyncService;
 import com.android.exchange.utility.CalendarUtilities;
+import com.android.mail.utils.LogUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -1067,10 +1067,10 @@
                 }
             } catch (RemoteException e) {
                 // There is nothing sensible to be done here
-                Log.e(TAG, "problem inserting contact during server update", e);
+                LogUtils.e(TAG, "problem inserting contact during server update", e);
             } catch (OperationApplicationException e) {
                 // There is nothing sensible to be done here
-                Log.e(TAG, "problem inserting contact during server update", e);
+                LogUtils.e(TAG, "problem inserting contact during server update", e);
             }
         }
 
@@ -1082,7 +1082,7 @@
          * @param type the subtype (e.g. HOME, WORK, etc.)
          * @return the matching NCV or null if not found
          */
-        private NamedContentValues findTypedData(ArrayList<NamedContentValues> list,
+        private static NamedContentValues findTypedData(ArrayList<NamedContentValues> list,
                 String contentItemType, int type, String stringType) {
             NamedContentValues result = null;
 
@@ -1127,8 +1127,8 @@
          * @param type the subtype (e.g. HOME, WORK, etc.)
          * @return the matching NCVs
          */
-        private ArrayList<NamedContentValues> findUntypedData(ArrayList<NamedContentValues> list,
-                int type, String contentItemType) {
+        private static ArrayList<NamedContentValues> findUntypedData(
+                ArrayList<NamedContentValues> list, int type, String contentItemType) {
             ArrayList<NamedContentValues> result = new ArrayList<NamedContentValues>();
 
             // Loop through the ncv's, looking for an existing row
@@ -1238,7 +1238,7 @@
          * @param oldValue an old value (or null) to check against
          * @return whether the column's value in the ContentValues matches oldValue
          */
-        private boolean cvCompareString(ContentValues cv, String column, String oldValue) {
+        private static boolean cvCompareString(ContentValues cv, String column, String oldValue) {
             if (cv.containsKey(column)) {
                 if (oldValue != null && cv.getAsString(column).equals(oldValue)) {
                     return true;
@@ -1625,7 +1625,7 @@
         }
     }
 
-    private void sendIm(Serializer s, ContentValues cv, int count) throws IOException {
+    private static void sendIm(Serializer s, ContentValues cv, int count) throws IOException {
         String value = cv.getAsString(Im.DATA);
         if (value == null) return;
         if (count < MAX_IM_ROWS) {
@@ -1633,7 +1633,7 @@
         }
     }
 
-    private void sendOnePostal(Serializer s, ContentValues cv, int[] fieldNames)
+    private static void sendOnePostal(Serializer s, ContentValues cv, int[] fieldNames)
             throws IOException{
         sendStringData(s, cv, StructuredPostal.CITY, fieldNames[0]);
         sendStringData(s, cv, StructuredPostal.COUNTRY, fieldNames[1]);
@@ -1642,7 +1642,7 @@
         sendStringData(s, cv, StructuredPostal.STREET, fieldNames[4]);
     }
 
-    private void sendStructuredPostal(Serializer s, ContentValues cv) throws IOException {
+    private static void sendStructuredPostal(Serializer s, ContentValues cv) throws IOException {
         switch (cv.getAsInteger(StructuredPostal.TYPE)) {
             case StructuredPostal.TYPE_HOME:
                 sendOnePostal(s, cv, HOME_ADDRESS_TAGS);
@@ -1658,7 +1658,7 @@
         }
     }
 
-    private void sendStringData(Serializer s, ContentValues cv, String column, int tag)
+    private static void sendStringData(Serializer s, ContentValues cv, String column, int tag)
             throws IOException {
         if (cv.containsKey(column)) {
             String value = cv.getAsString(column);
@@ -1668,7 +1668,7 @@
         }
     }
 
-    private String sendStructuredName(Serializer s, ContentValues cv) throws IOException {
+    private static String sendStructuredName(Serializer s, ContentValues cv) throws IOException {
         String displayName = null;
         sendStringData(s, cv, StructuredName.FAMILY_NAME, Tags.CONTACTS_LAST_NAME);
         sendStringData(s, cv, StructuredName.GIVEN_NAME, Tags.CONTACTS_FIRST_NAME);
@@ -1680,22 +1680,22 @@
         return displayName;
     }
 
-    private void sendBusiness(Serializer s, ContentValues cv) throws IOException {
+    private static void sendBusiness(Serializer s, ContentValues cv) throws IOException {
         sendStringData(s, cv, EasBusiness.ACCOUNT_NAME, Tags.CONTACTS2_ACCOUNT_NAME);
         sendStringData(s, cv, EasBusiness.CUSTOMER_ID, Tags.CONTACTS2_CUSTOMER_ID);
         sendStringData(s, cv, EasBusiness.GOVERNMENT_ID, Tags.CONTACTS2_GOVERNMENT_ID);
     }
 
-    private void sendPersonal(Serializer s, ContentValues cv) throws IOException {
+    private static void sendPersonal(Serializer s, ContentValues cv) throws IOException {
         sendStringData(s, cv, EasPersonal.ANNIVERSARY, Tags.CONTACTS_ANNIVERSARY);
         sendStringData(s, cv, EasPersonal.FILE_AS, Tags.CONTACTS_FILE_AS);
     }
 
-    private void sendBirthday(Serializer s, ContentValues cv) throws IOException {
+    private static void sendBirthday(Serializer s, ContentValues cv) throws IOException {
         sendStringData(s, cv, Event.START_DATE, Tags.CONTACTS_BIRTHDAY);
     }
 
-    private void sendPhoto(Serializer s, ContentValues cv) throws IOException {
+    private static void sendPhoto(Serializer s, ContentValues cv) throws IOException {
         if (cv.containsKey(Photo.PHOTO)) {
             byte[] bytes = cv.getAsByteArray(Photo.PHOTO);
             String pic = Base64.encodeToString(bytes, Base64.NO_WRAP);
@@ -1706,18 +1706,18 @@
         }
     }
 
-    private void sendOrganization(Serializer s, ContentValues cv) throws IOException {
+    private static void sendOrganization(Serializer s, ContentValues cv) throws IOException {
         sendStringData(s, cv, Organization.TITLE, Tags.CONTACTS_JOB_TITLE);
         sendStringData(s, cv, Organization.COMPANY, Tags.CONTACTS_COMPANY_NAME);
         sendStringData(s, cv, Organization.DEPARTMENT, Tags.CONTACTS_DEPARTMENT);
         sendStringData(s, cv, Organization.OFFICE_LOCATION, Tags.CONTACTS_OFFICE_LOCATION);
     }
 
-    private void sendNickname(Serializer s, ContentValues cv) throws IOException {
+    private static void sendNickname(Serializer s, ContentValues cv) throws IOException {
         sendStringData(s, cv, Nickname.NAME, Tags.CONTACTS2_NICKNAME);
     }
 
-    private void sendWebpage(Serializer s, ContentValues cv) throws IOException {
+    private static void sendWebpage(Serializer s, ContentValues cv) throws IOException {
         sendStringData(s, cv, Website.URL, Tags.CONTACTS_WEBPAGE);
     }
 
@@ -1739,7 +1739,7 @@
         }
     }
 
-    private void sendChildren(Serializer s, ContentValues cv) throws IOException {
+    private static void sendChildren(Serializer s, ContentValues cv) throws IOException {
         boolean first = true;
         for (int i = 0; i < EasChildren.MAX_CHILDREN; i++) {
             String row = EasChildren.ROWS[i];
@@ -1756,7 +1756,7 @@
         }
     }
 
-    private void sendPhone(Serializer s, ContentValues cv, int workCount, int homeCount)
+    private static void sendPhone(Serializer s, ContentValues cv, int workCount, int homeCount)
             throws IOException {
         String value = cv.getAsString(Phone.NUMBER);
         if (value == null) return;
@@ -1803,7 +1803,7 @@
         }
     }
 
-    private void sendRelation(Serializer s, ContentValues cv) throws IOException {
+    private static void sendRelation(Serializer s, ContentValues cv) throws IOException {
         String value = cv.getAsString(Relation.DATA);
         if (value == null) return;
         switch (cv.getAsInteger(Relation.TYPE)) {
diff --git a/src/com/android/exchange/adapter/EmailSyncAdapter.java b/src/com/android/exchange/adapter/EmailSyncAdapter.java
index 3f5d798..0d47554 100644
--- a/src/com/android/exchange/adapter/EmailSyncAdapter.java
+++ b/src/com/android/exchange/adapter/EmailSyncAdapter.java
@@ -32,7 +32,6 @@
 import android.text.SpannedString;
 import android.text.TextUtils;
 import android.util.Base64;
-import android.util.Log;
 import android.webkit.MimeTypeMap;
 
 import com.android.emailcommon.internet.MimeMessage;
@@ -66,6 +65,7 @@
 import com.android.exchange.MessageMoveRequest;
 import com.android.exchange.R;
 import com.android.exchange.utility.CalendarUtilities;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import org.apache.http.HttpStatus;
@@ -336,7 +336,7 @@
 
         CharSequence[] windowEntries = mContext.getResources().getTextArray(
                 R.array.account_settings_mail_window_entries);
-        Log.d(TAG, "Auto lookback: " + windowEntries[lookback]);
+        LogUtils.d(TAG, "Auto lookback: " + windowEntries[lookback]);
     }
 
     private static class GetItemEstimateParser extends Parser {
@@ -373,7 +373,7 @@
         public void parseResponse() throws IOException {
             while (nextTag(Tags.GIE_RESPONSE) != END) {
                 if (tag == Tags.GIE_STATUS) {
-                    Log.d(TAG, "GIE status: " + getValue());
+                    LogUtils.d(TAG, "GIE status: " + getValue());
                 } else if (tag == Tags.GIE_COLLECTION) {
                     parseCollection();
                 } else {
@@ -385,12 +385,12 @@
         public void parseCollection() throws IOException {
             while (nextTag(Tags.GIE_COLLECTION) != END) {
                 if (tag == Tags.GIE_CLASS) {
-                    Log.d(TAG, "GIE class: " + getValue());
+                    LogUtils.d(TAG, "GIE class: " + getValue());
                 } else if (tag == Tags.GIE_COLLECTION_ID) {
-                    Log.d(TAG, "GIE collectionId: " + getValue());
+                    LogUtils.d(TAG, "GIE collectionId: " + getValue());
                 } else if (tag == Tags.GIE_ESTIMATE) {
                     mEstimate = getValueInt();
-                    Log.d(TAG, "GIE estimate: " + mEstimate);
+                    LogUtils.d(TAG, "GIE estimate: " + mEstimate);
                 } else {
                     skipTag();
                 }
@@ -654,7 +654,7 @@
             }
         }
 
-        private void putFromMeeting(PackedString ps, String field, ContentValues values,
+        private static void putFromMeeting(PackedString ps, String field, ContentValues values,
                 String column) {
             String val = ps.get(field);
             if (!TextUtils.isEmpty(val)) {
@@ -807,7 +807,7 @@
          * @param mimeData the MIME data we've received from the server
          * @throws IOException
          */
-        private void mimeBodyParser(Message msg, String mimeData) throws IOException {
+        private static void mimeBodyParser(Message msg, String mimeData) throws IOException {
             try {
                 ByteArrayInputStream in = new ByteArrayInputStream(mimeData.getBytes());
                 // The constructor parses the message
@@ -1223,7 +1223,7 @@
                 mContentResolver.applyBatch(EmailContent.AUTHORITY, ops);
                 userLog(mMailbox.mDisplayName, " SyncKey saved as: ", mMailbox.mSyncKey);
             } catch (TransactionTooLargeException e) {
-                Log.w(TAG, "Transaction failed on fetched message; retrying...");
+                LogUtils.w(TAG, "Transaction failed on fetched message; retrying...");
                 commitImpl(++tryCount);
              } catch (RemoteException e) {
                 // There is nothing to be done here; fail by returning null
@@ -1273,7 +1273,7 @@
         }
     }
 
-    private String formatTwo(int num) {
+    private static String formatTwo(int num) {
         if (num < 10) {
             return "0" + (char)('0' + num);
         } else
@@ -1308,7 +1308,7 @@
      * can utilize this id to find references to the message.  The only reference situation at this
      * point is in the Body table; it is when sending messages via SmartForward and SmartReply
      */
-    private boolean messageReferenced(ContentResolver cr, long id) {
+    private static boolean messageReferenced(ContentResolver cr, long id) {
         // See if this id is referenced in a body
         Cursor c = cr.query(Body.CONTENT_URI, Body.ID_PROJECTION, WHERE_BODY_SOURCE_MESSAGE_KEY,
                 new String[] {Long.toString(id)}, null);
diff --git a/src/com/android/exchange/adapter/FolderSyncParser.java b/src/com/android/exchange/adapter/FolderSyncParser.java
index 422c50a..302e558 100644
--- a/src/com/android/exchange/adapter/FolderSyncParser.java
+++ b/src/com/android/exchange/adapter/FolderSyncParser.java
@@ -26,7 +26,6 @@
 import android.database.Cursor;
 import android.os.RemoteException;
 import android.text.TextUtils;
-import android.util.Log;
 
 import com.android.emailcommon.Logging;
 import com.android.emailcommon.provider.Account;
@@ -41,6 +40,7 @@
 import com.android.exchange.CommandStatusException.CommandStatus;
 import com.android.exchange.Eas;
 import com.android.exchange.ExchangeService;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import java.io.IOException;
@@ -178,7 +178,7 @@
                     // For verbose logging, make sure this is in emaillog.txt
                     userLog(e);
                     // Worthy of logging, regardless
-                    Log.w(Logging.LOG_TAG, e);
+                    LogUtils.w(Logging.LOG_TAG, e);
                     status = Eas.FOLDER_STATUS_INVALID_KEY;
                 }
                 if (status != Eas.FOLDER_STATUS_OK) {
diff --git a/src/com/android/exchange/adapter/Parser.java b/src/com/android/exchange/adapter/Parser.java
index d24e6c1..3b47a48 100644
--- a/src/com/android/exchange/adapter/Parser.java
+++ b/src/com/android/exchange/adapter/Parser.java
@@ -18,11 +18,11 @@
 package com.android.exchange.adapter;
 
 import android.content.Context;
-import android.util.Log;
 
 import com.android.exchange.Eas;
 import com.android.exchange.EasException;
 import com.android.exchange.utility.FileLogger;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import java.io.ByteArrayOutputStream;
@@ -176,8 +176,8 @@
     }
 
     /**
-     * Set the debug state of the parser.  When debugging is on, every token is logged (Log.v) to
-     * the console.
+     * Set the debug state of the parser.  When debugging is on, every token is logged (LogUtils.v)
+     * to the console.
      *
      * @param val the desired state for debug output
      */
@@ -190,7 +190,7 @@
     }
 
     /**
-     * Set the tag used for logging.  When debugging is on, every token is logged (Log.v) to
+     * Set the tag used for logging.  When debugging is on, every token is logged (LogUtils.v) to
      * the console.
      *
      * @param val the logging tag
@@ -390,7 +390,7 @@
         if (cr > 0) {
             str = str.substring(0, cr);
         }
-        Log.v(logTag, str);
+        LogUtils.v(logTag, str);
         if (Eas.FILE_LOG) {
             FileLogger.log(logTag, str);
         }
diff --git a/src/com/android/exchange/adapter/Search.java b/src/com/android/exchange/adapter/Search.java
index d10e095..2003dd4 100644
--- a/src/com/android/exchange/adapter/Search.java
+++ b/src/com/android/exchange/adapter/Search.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.content.OperationApplicationException;
 import android.os.RemoteException;
-import android.util.Log;
 
 import com.android.emailcommon.Logging;
 import com.android.emailcommon.provider.Account;
@@ -37,6 +36,7 @@
 import com.android.exchange.ExchangeService;
 import com.android.exchange.adapter.EmailSyncAdapter.EasEmailSyncParser;
 import com.android.mail.providers.UIProvider;
+import com.android.mail.utils.LogUtils;
 
 import org.apache.http.HttpStatus;
 
@@ -173,7 +173,7 @@
                 if (tag == Tags.SEARCH_STATUS) {
                     String status = getValue();
                     if (Eas.USER_LOG) {
-                        Log.d(Logging.LOG_TAG, "Search status: " + status);
+                        LogUtils.d(Logging.LOG_TAG, "Search status: " + status);
                     }
                 } else if (tag == Tags.SEARCH_RESPONSE) {
                     parseResponse();
@@ -220,7 +220,7 @@
                     mService.userLog("Saved " + ops.size() + " search results");
                 }
             } catch (RemoteException e) {
-                Log.d(Logging.LOG_TAG, "RemoteException while saving search results.");
+                LogUtils.d(Logging.LOG_TAG, "RemoteException while saving search results.");
             } catch (OperationApplicationException e) {
             }
 
diff --git a/src/com/android/exchange/adapter/Serializer.java b/src/com/android/exchange/adapter/Serializer.java
index bc79603..960be47 100644
--- a/src/com/android/exchange/adapter/Serializer.java
+++ b/src/com/android/exchange/adapter/Serializer.java
@@ -24,10 +24,10 @@
 package com.android.exchange.adapter;
 
 import android.content.ContentValues;
-import android.util.Log;
 
 import com.android.exchange.Eas;
 import com.android.exchange.utility.FileLogger;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import java.io.ByteArrayOutputStream;
@@ -45,7 +45,7 @@
     private int mDepth;
     private String[] mNameStack = new String[20];
     private int mTagPage = 0;
-    private boolean mLogging = Log.isLoggable(TAG, Log.VERBOSE);
+    private boolean mLogging = LogUtils.isLoggable(TAG, LogUtils.VERBOSE);
 
     public Serializer() throws IOException {
         this(new ByteArrayOutputStream(), true);
@@ -82,7 +82,7 @@
         if (cr > 0) {
             str = str.substring(0, cr);
         }
-        Log.v(TAG, str);
+        LogUtils.v(TAG, str);
         if (Eas.FILE_LOG) {
             FileLogger.log(TAG, str);
         }
@@ -151,7 +151,7 @@
 
     public Serializer data(int tag, String value) throws IOException {
         if (value == null) {
-            Log.e(TAG, "Writing null data for tag: " + tag);
+            LogUtils.e(TAG, "Writing null data for tag: " + tag);
         }
         start(tag);
         text(value);
@@ -161,7 +161,7 @@
 
     public Serializer text(String text) throws IOException {
         if (text == null) {
-            Log.e(TAG, "Writing null text for pending tag: " + mPendingTag);
+            LogUtils.e(TAG, "Writing null text for pending tag: " + mPendingTag);
         }
         checkPendingTag(false);
         mOutput.write(Wbxml.STR_I);
diff --git a/src/com/android/exchange/service/CalendarSyncAdapterService.java b/src/com/android/exchange/service/CalendarSyncAdapterService.java
index 8a8cb5c..76f3bd6 100644
--- a/src/com/android/exchange/service/CalendarSyncAdapterService.java
+++ b/src/com/android/exchange/service/CalendarSyncAdapterService.java
@@ -25,14 +25,13 @@
 import android.database.Cursor;
 import android.os.Bundle;
 import android.provider.CalendarContract.Events;
-import android.util.Log;
 
 import com.android.emailcommon.provider.EmailContent;
 import com.android.emailcommon.provider.EmailContent.AccountColumns;
 import com.android.emailcommon.provider.EmailContent.MailboxColumns;
 import com.android.emailcommon.provider.Mailbox;
 import com.android.exchange.Eas;
-import com.android.exchange.ExchangeService;
+import com.android.mail.utils.LogUtils;
 
 public class CalendarSyncAdapterService extends AbstractSyncAdapterService {
     private static final String TAG = "EAS CalendarSyncAdapterService";
@@ -79,7 +78,7 @@
             try {
                 if (!c.moveToFirst()) {
                     if (logging) {
-                        Log.d(TAG, "No changes for " + account.name);
+                        LogUtils.d(TAG, "No changes for " + account.name);
                     }
                     return;
                 }
@@ -94,7 +93,7 @@
                     EmailContent.ID_PROJECTION, AccountColumns.EMAIL_ADDRESS + "=?",
                     new String[] {account.name}, null);
         if (accountCursor == null) {
-            Log.e(TAG, "Null account cursor in CalendarSyncAdapterService");
+            LogUtils.e(TAG, "Null account cursor in CalendarSyncAdapterService");
             return;
         }
 
@@ -107,7 +106,7 @@
                 try {
                     if (mailboxCursor.moveToFirst()) {
                         if (logging) {
-                            Log.d(TAG, "Upload sync requested for " + account.name);
+                            LogUtils.d(TAG, "Upload sync requested for " + account.name);
                         }
                         // TODO: Currently just bouncing this to Email sync; eventually streamline.
                         final long mailboxId = mailboxCursor.getLong(Mailbox.ID_PROJECTION_COLUMN);
diff --git a/src/com/android/exchange/service/ContactsSyncAdapterService.java b/src/com/android/exchange/service/ContactsSyncAdapterService.java
index 9ed9972..37348c8 100644
--- a/src/com/android/exchange/service/ContactsSyncAdapterService.java
+++ b/src/com/android/exchange/service/ContactsSyncAdapterService.java
@@ -21,7 +21,7 @@
 import com.android.emailcommon.provider.EmailContent.MailboxColumns;
 import com.android.emailcommon.provider.Mailbox;
 import com.android.exchange.Eas;
-import com.android.exchange.ExchangeService;
+import com.android.mail.utils.LogUtils;
 
 import android.accounts.Account;
 import android.content.AbstractThreadedSyncAdapter;
@@ -34,7 +34,6 @@
 import android.os.Bundle;
 import android.provider.ContactsContract.Groups;
 import android.provider.ContactsContract.RawContacts;
-import android.util.Log;
 
 public class ContactsSyncAdapterService extends AbstractSyncAdapterService {
     private static final String TAG = "EAS ContactsSyncAdapterService";
@@ -99,7 +98,7 @@
                 changed = hasDirtyRows(cr, uri, Groups.DIRTY);
             }
             if (!changed) {
-                Log.i(TAG, "Upload sync; no changes");
+                LogUtils.i(TAG, "Upload sync; no changes");
                 return;
             }
         }
@@ -111,7 +110,7 @@
                     AccountColumns.EMAIL_ADDRESS + "=?",
                     new String[] {account.name}, null);
         if (accountCursor == null) {
-            Log.e(TAG, "null account cursor in ContactsSyncAdapterService");
+            LogUtils.e(TAG, "null account cursor in ContactsSyncAdapterService");
             return;
         }
 
@@ -124,7 +123,7 @@
                         ACCOUNT_AND_TYPE_CONTACTS, new String[] {Long.toString(accountId)}, null);
                 try {
                      if (mailboxCursor.moveToFirst()) {
-                        Log.i(TAG, "Contact sync requested for " + account.name);
+                         LogUtils.i(TAG, "Contact sync requested for " + account.name);
                          // TODO: Currently just bouncing this to Email sync; eventually streamline.
                         final long mailboxId = mailboxCursor.getLong(Mailbox.ID_PROJECTION_COLUMN);
                          // TODO: Should we be using the existing extras and just adding our bits?
diff --git a/src/com/android/exchange/service/EmailSyncAdapterService.java b/src/com/android/exchange/service/EmailSyncAdapterService.java
index 399f298..d4428f1 100644
--- a/src/com/android/exchange/service/EmailSyncAdapterService.java
+++ b/src/com/android/exchange/service/EmailSyncAdapterService.java
@@ -31,6 +31,7 @@
 import com.android.exchange.Eas;
 import com.android.exchange.adapter.Search;
 import com.android.mail.providers.UIProvider.AccountCapabilities;
+import com.android.mail.utils.LogUtils;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -44,8 +45,6 @@
 import android.database.Cursor;
 import android.os.Bundle;
 import android.os.IBinder;
-import android.util.Log;
-import com.android.mail.utils.LogUtils;
 
 /**
  * Service for communicating with Exchange servers. There are three main parts of this class:
@@ -238,13 +237,13 @@
     private final IEmailService.Stub mBinder = new IEmailService.Stub() {
         @Override
         public Bundle validate(final HostAuth hostAuth) {
-            Log.d(TAG, "IEmailService.validate");
+            LogUtils.d(TAG, "IEmailService.validate");
             return new EasAccountValidator(EmailSyncAdapterService.this, hostAuth).validate();
         }
 
         @Override
         public Bundle autoDiscover(final String userName, final String password) {
-            Log.d(TAG, "IEmailService.autoDiscover");
+            LogUtils.d(TAG, "IEmailService.autoDiscover");
             HostAuth hostAuth = new HostAuth();
             hostAuth.mLogin = userName;
             hostAuth.mPassword = password;
@@ -256,7 +255,7 @@
 
         @Override
         public void updateFolderList(final long accountId) {
-            Log.d(TAG, "IEmailService.updateFolderList");
+            LogUtils.d(TAG, "IEmailService.updateFolderList");
             final String emailAddress = Utility.getFirstRowString(EmailSyncAdapterService.this,
                     Account.CONTENT_URI, new String[] {AccountColumns.EMAIL_ADDRESS},
                     Account.ID_SELECTION, new String[] {Long.toString(accountId)}, null, 0);
@@ -284,7 +283,7 @@
 
         @Override
         public void loadAttachment(final long attachmentId, final boolean background) {
-            Log.d(TAG, "IEmailService.loadAttachment");
+            LogUtils.d(TAG, "IEmailService.loadAttachment");
             // TODO: Implement.
             /*
             Attachment att = Attachment.restoreAttachmentWithId(ExchangeService.this, attachmentId);
@@ -295,7 +294,7 @@
 
         @Override
         public void sendMeetingResponse(final long messageId, final int response) {
-            Log.d(TAG, "IEmailService.sendMeetingResponse");
+            LogUtils.d(TAG, "IEmailService.sendMeetingResponse");
             // TODO: Implement.
             //sendMessageRequest(new MeetingResponseRequest(messageId, response));
         }
@@ -307,7 +306,7 @@
          */
         @Override
         public void deleteAccountPIMData(final long accountId) {
-            Log.d(TAG, "IEmailService.deleteAccountPIMData");
+            LogUtils.d(TAG, "IEmailService.deleteAccountPIMData");
             // TODO: Implement
             /*
             SyncManager exchangeService = INSTANCE;
@@ -451,7 +450,7 @@
             // for this sync operation.
 
             final Context context = getContext();
-            Log.i(TAG, "performSync");
+            LogUtils.i(TAG, "performSync");
             final ContentResolver cr = context.getContentResolver();
 
             // Get the EmailContent Account
diff --git a/src/com/android/exchange/service/ExchangeBroadcastProcessorService.java b/src/com/android/exchange/service/ExchangeBroadcastProcessorService.java
index 707595b..91eba00 100644
--- a/src/com/android/exchange/service/ExchangeBroadcastProcessorService.java
+++ b/src/com/android/exchange/service/ExchangeBroadcastProcessorService.java
@@ -20,13 +20,12 @@
 import android.app.IntentService;
 import android.content.Context;
 import android.content.Intent;
-import android.util.Log;
 
 import com.android.emailcommon.Logging;
 import com.android.emailcommon.service.AccountServiceProxy;
-import com.android.emailsync.SyncManager;
 import com.android.exchange.Eas;
 import com.android.exchange.ExchangeService;
+import com.android.mail.utils.LogUtils;
 
 /**
  * The service that really handles broadcast intents on a worker thread.
@@ -71,7 +70,7 @@
                 onBootCompleted();
             } else if (AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(broadcastAction)) {
                 if (Eas.USER_LOG) {
-                    Log.d(Logging.LOG_TAG, "Login accounts changed; reconciling...");
+                    LogUtils.d(Logging.LOG_TAG, "Login accounts changed; reconciling...");
                 }
                 new AccountServiceProxy(this).reconcileAccounts(Eas.PROTOCOL,
                         Eas.EXCHANGE_ACCOUNT_MANAGER_TYPE);
diff --git a/src/com/android/exchange/utility/CalendarUtilities.java b/src/com/android/exchange/utility/CalendarUtilities.java
index f9f02a0..eca3f0a 100644
--- a/src/com/android/exchange/utility/CalendarUtilities.java
+++ b/src/com/android/exchange/utility/CalendarUtilities.java
@@ -33,7 +33,6 @@
 import android.text.TextUtils;
 import android.text.format.Time;
 import android.util.Base64;
-import android.util.Log;
 
 import com.android.calendarcommon2.DateException;
 import com.android.calendarcommon2.Duration;
@@ -47,11 +46,11 @@
 import com.android.emailcommon.service.AccountServiceProxy;
 import com.android.emailcommon.utility.Utility;
 import com.android.exchange.Eas;
-import com.android.exchange.EasSyncService;
 import com.android.exchange.ExchangeService;
 import com.android.exchange.R;
 import com.android.exchange.adapter.Serializer;
 import com.android.exchange.adapter.Tags;
+import com.android.mail.utils.LogUtils;
 import com.google.common.annotations.VisibleForTesting;
 
 import java.io.IOException;
@@ -1379,7 +1378,7 @@
         }
 
         if (Eas.USER_LOG) {
-            Log.d(Logging.LOG_TAG, "Created rrule: " + rrule);
+            LogUtils.d(Logging.LOG_TAG, "Created rrule: " + rrule);
         }
         return rrule.toString();
     }
@@ -1983,7 +1982,7 @@
             msg.mAttachments = new ArrayList<Attachment>();
             msg.mAttachments.add(att);
         } catch (IOException e) {
-            Log.w(TAG, "IOException in createMessageForEntity");
+            LogUtils.w(TAG, "IOException in createMessageForEntity");
             return null;
         }
 
diff --git a/tests/src/com/android/exchange/CalendarSyncEnablerTest.java b/tests/src/com/android/exchange/CalendarSyncEnablerTest.java
index 2c90dbb..b70d308 100644
--- a/tests/src/com/android/exchange/CalendarSyncEnablerTest.java
+++ b/tests/src/com/android/exchange/CalendarSyncEnablerTest.java
@@ -29,16 +29,17 @@
 import android.test.MoreAsserts;
 import android.test.suitebuilder.annotation.MediumTest;
 import android.text.TextUtils;
-import android.util.Log;
 
 import com.android.emailcommon.Logging;
 import com.android.exchange.utility.ExchangeTestCase;
+import com.android.mail.utils.LogUtils;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
+
 @MediumTest
 public class CalendarSyncEnablerTest extends ExchangeTestCase {
 
@@ -178,7 +179,7 @@
         // set up on the device.  Otherwise there'll be no difference from
         // testEnableEasCalendarSync.
         if (AccountManager.get(getContext()).getAccountsByType(EAT).length > 0) {
-            Log.w(Logging.LOG_TAG, "testEnableEasCalendarSyncWithNoExchangeAccounts skipped:"
+            LogUtils.w(Logging.LOG_TAG, "testEnableEasCalendarSyncWithNoExchangeAccounts skipped:"
                     + " It only runs when there's no Exchange account on the device.");
             return;
         }
diff --git a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
index 77820a5..fc9eb34 100644
--- a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
+++ b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
@@ -22,7 +22,6 @@
 import android.provider.CalendarContract.Attendees;
 import android.provider.CalendarContract.Events;
 import android.test.suitebuilder.annotation.MediumTest;
-import android.util.Log;
 
 import com.android.emailcommon.mail.Address;
 import com.android.emailcommon.provider.Account;
@@ -36,6 +35,7 @@
 import com.android.exchange.adapter.Serializer;
 import com.android.exchange.adapter.SyncAdapterTestCase;
 import com.android.exchange.adapter.Tags;
+import com.android.mail.utils.LogUtils;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -880,10 +880,10 @@
                 nodst++;
             }
         }
-        Log.d("TimeZoneGeneration",
+        LogUtils.d("TimeZoneGeneration",
                 "Rule: " + rule + ", No DST: " + nodst + ", No rule: " + norule);
         for (String nr: norulelist) {
-            Log.d("TimeZoneGeneration", "No rule: " + nr);
+            LogUtils.d("TimeZoneGeneration", "No rule: " + nr);
         }
         // This is an empirical sanity test; we shouldn't have too many time zones with DST and
         // without a rule.