Skip to content

Commit

Permalink
add loggers instead of e.printStackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlittle committed Feb 7, 2019
1 parent f02251e commit 9b56c7a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.webkit.WebView;
import android.widget.TextView;

import com.splunk.mint.Mint;

import org.digitalcampus.mobile.learning.R;
import org.digitalcampus.oppia.model.Course;
import org.digitalcampus.oppia.model.CourseMetaPage;
Expand Down Expand Up @@ -76,7 +79,8 @@ public void onCreate(Bundle savedInstanceState) {
content += "</html>";
wv.loadDataWithBaseURL("file://" + course.getLocation() + File.separator, content, "text/html", "utf-8", null);
} catch (IOException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "IOException: ", e);
wv.loadUrl("file://" + url);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void refreshCourseList() {

} catch (Exception e) {
Mint.logException(e);
e.printStackTrace();
Log.d(TAG, "Error processing response: ", e);
UIUtils.showAlert(this, R.string.loading, R.string.error_processing_response);
}

Expand All @@ -227,7 +227,7 @@ public Boolean call() throws Exception {

} catch (JSONException e) {
Mint.logException(e);
e.printStackTrace();
Log.d(TAG, "Error connecting to server: ", e);
UIUtils.showAlert(this, R.string.loading, R.string.error_connection, finishActivity);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
Expand Down Expand Up @@ -121,7 +122,10 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {
}

this.json = new JSONObject(savedInstanceState.getString("json"));
} catch (Exception e) { e.printStackTrace(); }
} catch (Exception e) {
Mint.logException(e);
Log.d(TAG, "Error restoring saved state: ", e);
}
}

@Override
Expand Down Expand Up @@ -154,7 +158,8 @@ public void refreshTagList() {
findViewById(R.id.empty_state).setVisibility((tags.isEmpty()) ? View.VISIBLE : View.GONE);

} catch (JSONException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "Error refreshing tag list: ", e);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import android.util.Pair;

import com.splunk.mint.Mint;
Expand All @@ -39,6 +40,8 @@

public class SessionManager {

public static final String TAG = SessionManager.class.getSimpleName();

public static final String ACCOUNTS_CSV_FILENAME = "oppia_accounts.csv";
public static final String APIKEY_VALID = "prefApiKeyInvalid";

Expand All @@ -61,7 +64,8 @@ public static String getUserDisplayName(Context ctx){
return u.getDisplayName();

} catch (UserNotFoundException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "User not found: ", e);
return null;
}

Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/org/digitalcampus/oppia/application/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

import com.splunk.mint.Mint;

public class Tracker {

Expand All @@ -48,7 +51,8 @@ private void saveTracker(int courseId, String digest, JSONObject data, String ty
try {
data.put("uuid", guid.toString());
} catch (JSONException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "error with uuid: ", e);
}
DbHelper db = DbHelper.getInstance(this.ctx);

Expand All @@ -74,7 +78,8 @@ public void saveSearchTracker(String searchTerm, int count){
saveTracker(0, "", searchData, SEARCH_TYPE, true, Gamification.GAMIFICATION_SEARCH_PERFORMED);

} catch (JSONException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "Errors saving search tracker: ", e);
}
}

Expand All @@ -87,7 +92,8 @@ public void saveMissingMediaTracker(String filename){
saveTracker(0, "", missingMedia, MISSING_MEDIA_TYPE, true, Gamification.GAMIFICATION_MEDIA_MISSING);

} catch (JSONException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "Error saving missing media tracker: ", e);
}
}

Expand All @@ -100,7 +106,8 @@ public void saveRegisterTracker(){
saveTracker(0, "", registerData, Gamification.EVENT_NAME_REGISTER, true, Gamification.GAMIFICATION_REGISTER);

} catch (JSONException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "Error saving register tracker:", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.util.Log;

import com.splunk.mint.Mint;

import org.digitalcampus.oppia.api.ApiEndpoint;
import org.digitalcampus.oppia.api.RemoteApiEndpoint;
Expand All @@ -18,6 +21,8 @@

public abstract class APIRequestTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {

public static final String TAG = APIRequestTask.class.getSimpleName();

protected Context ctx;
protected SharedPreferences prefs;
protected ApiEndpoint apiEndpoint;
Expand All @@ -44,7 +49,8 @@ protected Request createRequestWithUserAuth(String url){
.build();

} catch (UserNotFoundException e) {
e.printStackTrace();
Mint.logException(e);
Log.d(TAG, "User not found: ", e);
}

if (request == null){
Expand Down

0 comments on commit 9b56c7a

Please sign in to comment.