package com.helpshift.migrator; import android.content.SharedPreferences; import android.util.Log; import com.helpshift.util.Utils; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes3.dex */ public class MigrationLogger { public final SharedPreferences sharedPreferences; public void d(String str, String str2) { } public MigrationLogger(SharedPreferences sharedPreferences) { this.sharedPreferences = sharedPreferences; } public void e(String str, String str2) { e(str, str2, null); } public void e(String str, String str2, Throwable th) { Log.e(str, str2, th); try { String stackTraceToString = stackTraceToString(th); String string = this.sharedPreferences.getString("error_logs", ""); JSONArray jSONArray = Utils.isEmpty(string) ? new JSONArray() : new JSONArray(string); JSONObject jSONObject = new JSONObject(); jSONObject.put("timestamp", System.currentTimeMillis()); jSONObject.put("message", str2); jSONObject.put("error", stackTraceToString); jSONArray.put(jSONObject); this.sharedPreferences.edit().putString("error_logs", jSONArray.toString()).commit(); } catch (Exception e) { Log.e("Helpshift_mgrtLog", "Error setting error logs in prefs", e); } } public final String stackTraceToString(Throwable th) { if (th == null) { return ""; } return th.getMessage() + " \n " + Log.getStackTraceString(th); } }