Bug 739519 - Part 2: logging. r=trivial
authorRichard Newman <rnewman@mozilla.com>
Wed, 28 Mar 2012 17:25:24 -0700
changeset 92048 d8c5280f2fda4502ea8972ed6671b624b0883f16
parent 92047 7f4f6e54eb27c49f4d8621400142b8178b2a88d6
child 92049 328ae1116d50892a2939142001d4d1b2db38d801
push idunknown
push userunknown
push dateunknown
reviewerstrivial
bugs739519
milestone13.0a2
Bug 739519 - Part 2: logging. r=trivial
mobile/android/base/sync/net/SyncStorageRequest.java
--- a/mobile/android/base/sync/net/SyncStorageRequest.java
+++ b/mobile/android/base/sync/net/SyncStorageRequest.java
@@ -6,28 +6,26 @@ package org.mozilla.gecko.sync.net;
 
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.GeneralSecurityException;
 import java.util.HashMap;
 
 import org.mozilla.gecko.sync.GlobalConstants;
-
-import android.util.Log;
+import org.mozilla.gecko.sync.Logger;
 
 import ch.boye.httpclientandroidlib.HttpEntity;
 import ch.boye.httpclientandroidlib.HttpResponse;
 import ch.boye.httpclientandroidlib.client.ClientProtocolException;
 import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
 import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
 import ch.boye.httpclientandroidlib.params.CoreProtocolPNames;
 
 public class SyncStorageRequest implements Resource {
-
   public static HashMap<String, String> SERVER_ERROR_MESSAGES;
   static {
     HashMap<String, String> errors = new HashMap<String, String>();
 
     // Sync protocol errors.
     errors.put("1", "Illegal method/protocol");
     errors.put("2", "Incorrect/missing CAPTCHA");
     errors.put("3", "Invalid/missing username");
@@ -94,28 +92,28 @@ public class SyncStorageRequest implemen
 
     @Override
     public String getCredentials() {
       return this.request.delegate.credentials();
     }
 
     @Override
     public void handleHttpResponse(HttpResponse response) {
-      Log.d(LOG_TAG, "SyncStorageResourceDelegate handling response: " + response.getStatusLine() + ".");
+      Logger.debug(LOG_TAG, "SyncStorageResourceDelegate handling response: " + response.getStatusLine() + ".");
       SyncStorageRequestDelegate d = this.request.delegate;
       SyncStorageResponse res = new SyncStorageResponse(response);
       // It is the responsibility of the delegate handlers to completely consume the response.
       if (res.wasSuccessful()) {
         d.handleRequestSuccess(res);
       } else {
-        Log.w(LOG_TAG, "HTTP request failed.");
+        Logger.warn(LOG_TAG, "HTTP request failed.");
         try {
-          Log.w(LOG_TAG, "HTTP response body: " + res.getErrorMessage());
+          Logger.warn(LOG_TAG, "HTTP response body: " + res.getErrorMessage());
         } catch (Exception e) {
-          Log.e(LOG_TAG, "Can't fetch HTTP response body.", e);
+          Logger.error(LOG_TAG, "Can't fetch HTTP response body.", e);
         }
         d.handleRequestFailure(res);
       }
     }
 
     @Override
     public void handleHttpProtocolException(ClientProtocolException e) {
       this.request.delegate.handleRequestError(e);
@@ -133,16 +131,17 @@ public class SyncStorageRequest implemen
 
     @Override
     public void addHeaders(HttpRequestBase request, DefaultHttpClient client) {
       client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, GlobalConstants.USER_AGENT);
 
       // Clients can use their delegate interface to specify X-If-Unmodified-Since.
       String ifUnmodifiedSince = this.request.delegate.ifUnmodifiedSince();
       if (ifUnmodifiedSince != null) {
+        Logger.debug(LOG_TAG, "Making request with X-If-Unmodified-Since = " + ifUnmodifiedSince);
         request.setHeader("x-if-unmodified-since", ifUnmodifiedSince);
       }
       if (request.getMethod().equalsIgnoreCase("DELETE")) {
         request.addHeader("x-confirm-delete", "1");
       }
     }
   }