From: Eugene Crosser Date: Wed, 8 Feb 2012 11:26:07 +0000 (+0400) Subject: enable HTTP logging X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=ead6205fe0e2f7f14d8d1f6a62292508112be96d;p=WhereAmI.git enable HTTP logging --- diff --git a/src/org/average/whereami/Oracle.java b/src/org/average/whereami/Oracle.java index 405e2dd..b3d992e 100644 --- a/src/org/average/whereami/Oracle.java +++ b/src/org/average/whereami/Oracle.java @@ -3,6 +3,11 @@ package org.average.whereami; 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; @@ -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; + enableLogging(); } private class MyAccessProtectedResource @@ -76,4 +82,19 @@ abstract public class Oracle { } 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()); + } + }); + } }