Skip to content

Commit

Permalink
Merge pull request #39 from flipkart-incubator/slf4j
Browse files Browse the repository at this point in the history
Removed slf4j dependency
  • Loading branch information
anirudhramanan authored Sep 1, 2016
2 parents 8350838 + 3da56e1 commit 5c44117
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
3 changes: 1 addition & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<OnResponseListener> mOnResponseListeners = new HashSet<>();
private int mResponseCount = 0;
private int MAX_SIZE;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@
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;
import com.flipkart.okhttpstats.response.CountingInputStream;
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;
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5c44117

Please sign in to comment.