]> average.org Git - WhereAmI.git/commitdiff
enable HTTP logging
authorEugene Crosser <Eugene.Crosser@ru.ibm.com>
Wed, 8 Feb 2012 11:26:07 +0000 (15:26 +0400)
committerEugene Crosser <Eugene.Crosser@ru.ibm.com>
Wed, 8 Feb 2012 11:26:07 +0000 (15:26 +0400)
src/org/average/whereami/Oracle.java

index 405e2ddd97157eb38fc7fd7b4befcacf4b4ea1a1..b3d992e410a437fe0e9852407aa7d830854696f5 100644 (file)
@@ -3,6 +3,11 @@ package org.average.whereami;
 import org.average.whereami.PersistentStore;
 
 import java.io.IOException;
 import org.average.whereami.PersistentStore;
 
 import java.io.IOException;
+import com.google.api.client.http.HttpTransport;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
 
 import com.google.api.client.extensions.android2.AndroidHttp;
 import com.google.api.client.auth.oauth2.draft10.AccessTokenResponse;
 
 import com.google.api.client.extensions.android2.AndroidHttp;
 import com.google.api.client.auth.oauth2.draft10.AccessTokenResponse;
@@ -29,6 +34,7 @@ abstract public class Oracle {
        public Oracle(final Resources res, final PersistentStore store) {
                authErrorMessage = res.getString(R.string.autherror);
                this.store = store;
        public Oracle(final Resources res, final PersistentStore store) {
                authErrorMessage = res.getString(R.string.autherror);
                this.store = store;
+               enableLogging();
        }
 
        private class MyAccessProtectedResource
        }
 
        private class MyAccessProtectedResource
@@ -76,4 +82,19 @@ abstract public class Oracle {
        }
 
        abstract public String getResult();
        }
 
        abstract public String getResult();
+
+       public static void enableLogging() {
+               Logger logger = Logger.getLogger(HttpTransport.class.getName());
+               logger.setLevel(Level.CONFIG);
+               logger.addHandler(new Handler() {
+                       @Override
+                       public void close() throws SecurityException {}
+                       @Override
+                       public void flush() {}
+                       @Override
+                       public void publish(LogRecord record) {
+                               Log.v("HttpTransport", record.getMessage());
+                       }
+               });
+       }
 }
 }