diff --git a/library/build.gradle b/library/build.gradle index 4f2c145..93a0585 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -60,8 +60,7 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:support-annotations:24.1.0' - compile 'org.slf4j:slf4j-api:1.7.6' + compile 'com.android.support:support-annotations:24.2.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' testCompile 'junit:junit:4.12' diff --git a/library/src/main/java/com/flipkart/okhttpstats/handler/PersistentStatsHandler.java b/library/src/main/java/com/flipkart/okhttpstats/handler/PersistentStatsHandler.java index 2796a18..4311a62 100644 --- a/library/src/main/java/com/flipkart/okhttpstats/handler/PersistentStatsHandler.java +++ b/library/src/main/java/com/flipkart/okhttpstats/handler/PersistentStatsHandler.java @@ -30,15 +30,13 @@ import android.net.wifi.WifiManager; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; +import android.util.Log; import com.flipkart.okhttpstats.model.RequestStats; import com.flipkart.okhttpstats.toolbox.NetworkStat; import com.flipkart.okhttpstats.toolbox.PreferenceManager; import com.flipkart.okhttpstats.toolbox.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.util.HashSet; import java.util.Set; @@ -60,7 +58,6 @@ public class PersistentStatsHandler implements NetworkRequestStatsHandler { private static final String MOBILE_NETWORK = "mobile"; private static final String UNKNOWN_NETWORK = "unknown"; private final PreferenceManager mPreferenceManager; - private Logger mLogger = LoggerFactory.getLogger(PersistentStatsHandler.class); private Set mOnResponseListeners = new HashSet<>(); private int mResponseCount = 0; private int MAX_SIZE; @@ -148,7 +145,7 @@ public float getAverageNetworkSpeed() { @Override public void onResponseReceived(final RequestStats requestStats) { if (Utils.isLoggingEnabled()) { - mLogger.debug("Response Received : {}", requestStats); + Log.d("Response Received : ", requestStats + " "); } //call all the registered listeners @@ -180,7 +177,7 @@ private float calculateNewSpeed(float currentAvgSpeed) { @Override public void onHttpExchangeError(RequestStats requestStats, IOException e) { if (Utils.isLoggingEnabled()) { - mLogger.debug("Response Received With Http Exchange Error : {}", requestStats); + Log.d("Response Http Error :", requestStats + ""); } for (OnResponseListener onResponseListener : mOnResponseListeners) { @@ -193,7 +190,7 @@ public void onHttpExchangeError(RequestStats requestStats, IOException e) { @Override public void onResponseInputStreamError(RequestStats requestStats, Exception e) { if (Utils.isLoggingEnabled()) { - mLogger.debug("Response Received With InputStream Error : {}", requestStats); + Log.d("Response InputStream : ", requestStats + ""); } for (OnResponseListener onResponseListener : mOnResponseListeners) { @@ -210,7 +207,7 @@ public void onResponseInputStreamError(RequestStats requestStats, Exception e) { */ private void saveToSharedPreference(float currentAvgSpeed) { if (Utils.isLoggingEnabled()) { - mLogger.debug("avg speed", "saveToSharedPreference: " + mNetworkStat.getCurrentAvgSpeed()); + Log.d("avg speed", "saveToSharedPreference: " + mNetworkStat.getCurrentAvgSpeed()); } String networkKey = getNetworkKey(getActiveNetworkInfo()); mPreferenceManager.setAverageSpeed(networkKey, currentAvgSpeed); diff --git a/library/src/main/java/com/flipkart/okhttpstats/interpreter/DefaultInterpreter.java b/library/src/main/java/com/flipkart/okhttpstats/interpreter/DefaultInterpreter.java index 7cbfa45..94a9b17 100644 --- a/library/src/main/java/com/flipkart/okhttpstats/interpreter/DefaultInterpreter.java +++ b/library/src/main/java/com/flipkart/okhttpstats/interpreter/DefaultInterpreter.java @@ -24,6 +24,7 @@ package com.flipkart.okhttpstats.interpreter; import android.support.annotation.VisibleForTesting; +import android.util.Log; import com.flipkart.okhttpstats.NetworkInterceptor; import com.flipkart.okhttpstats.reporter.NetworkEventReporter; @@ -31,9 +32,6 @@ import com.flipkart.okhttpstats.response.DefaultResponseHandler; import com.flipkart.okhttpstats.toolbox.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -51,7 +49,6 @@ public class DefaultInterpreter implements NetworkInterpreter { private static final String HOST_NAME = "HOST"; private static final String CONTENT_LENGTH = "Content-Length"; - private Logger logger = LoggerFactory.getLogger(DefaultInterpreter.class); private NetworkEventReporter mEventReporter; public DefaultInterpreter(NetworkEventReporter mEventReporter) { @@ -72,7 +69,7 @@ public Response interpretResponseStream(int requestId, NetworkInterceptor.TimeIn responseStream = body.byteStream(); } catch (Exception e) { if (Utils.isLoggingEnabled()) { - logger.debug("Error received while reading input stream {}", e.getMessage()); + Log.d("Error reading IS : ", e.getMessage()); } //notify event reporter in case there is any exception while getting the input stream of response @@ -102,7 +99,7 @@ public void onEOF(long bytesRead) { @Override public void interpretError(int requestId, NetworkInterceptor.TimeInfo timeInfo, Request request, IOException e) { if (Utils.isLoggingEnabled()) { - logger.debug("Error received while proceeding response {}", e.getMessage()); + Log.d("Error response: ", e.getMessage()); } final OkHttpInspectorRequest okHttpInspectorRequest = new OkHttpInspectorRequest(requestId, request.url().url(), request.method(), Utils.contentLength(request), request.header(HOST_NAME)); mEventReporter.httpExchangeError(okHttpInspectorRequest, e);