forked from github/szkolny
[3.9.2-dev] Add persistent debug logging.
This commit is contained in:
parent
3925496595
commit
434ddd1342
@ -164,6 +164,8 @@ dependencies {
|
||||
implementation "io.github.wulkanowy:signer-android:0.1.1"
|
||||
|
||||
implementation "androidx.work:work-runtime-ktx:${versions.work}"
|
||||
|
||||
implementation 'com.hypertrack:hyperlog:0.0.10'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -36,6 +36,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.hypertrack.hyperlog.HyperLog;
|
||||
import com.mikepenz.iconics.Iconics;
|
||||
import com.mikepenz.iconics.IconicsColor;
|
||||
import com.mikepenz.iconics.IconicsDrawable;
|
||||
@ -81,6 +82,7 @@ import pl.szczodrzynski.edziennik.network.NetworkUtils;
|
||||
import pl.szczodrzynski.edziennik.network.TLSSocketFactory;
|
||||
import pl.szczodrzynski.edziennik.sync.SyncWorker;
|
||||
import pl.szczodrzynski.edziennik.ui.modules.base.CrashActivity;
|
||||
import pl.szczodrzynski.edziennik.utils.DebugLogFormat;
|
||||
import pl.szczodrzynski.edziennik.utils.PermissionChecker;
|
||||
import pl.szczodrzynski.edziennik.utils.Themes;
|
||||
import pl.szczodrzynski.edziennik.utils.Utils;
|
||||
@ -294,6 +296,10 @@ public class App extends androidx.multidex.MultiDexApplication implements Config
|
||||
}
|
||||
|
||||
if (App.devMode || BuildConfig.DEBUG) {
|
||||
HyperLog.initialize(this);
|
||||
HyperLog.setLogLevel(Log.VERBOSE);
|
||||
HyperLog.setLogFormat(new DebugLogFormat(this));
|
||||
|
||||
ChuckerCollector chuckerCollector = new ChuckerCollector(this, true, RetentionManager.Period.ONE_HOUR);
|
||||
ChuckerInterceptor chuckerInterceptor = new ChuckerInterceptor(this, chuckerCollector);
|
||||
httpBuilder.addInterceptor(chuckerInterceptor);
|
||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -31,11 +32,13 @@ import androidx.work.WorkManager;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.chuckerteam.chucker.api.Chucker;
|
||||
import com.hypertrack.hyperlog.HyperLog;
|
||||
import com.mikepenz.iconics.IconicsColor;
|
||||
import com.mikepenz.iconics.IconicsDrawable;
|
||||
import com.mikepenz.iconics.IconicsSize;
|
||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -114,6 +117,19 @@ public class HomeFragment extends Fragment {
|
||||
startActivity(new Intent(activity, LoginLibrusCaptchaActivity.class));
|
||||
}));
|
||||
|
||||
b.getLogs.setOnClickListener((v -> {
|
||||
File logs = HyperLog.getDeviceLogsInFile(activity, true);
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
if(logs.exists()) {
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+logs.getAbsolutePath()));
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "Share debug logs");
|
||||
intent.putExtra(Intent.EXTRA_TEXT, "Share debug logs");
|
||||
startActivity(Intent.createChooser(intent, "Share debug logs"));
|
||||
}
|
||||
}));
|
||||
|
||||
//((TextView)v.findViewById(R.id.nextSync)).setText(getString(R.string.next_sync_format,Time.fromMillis(app.appJobs.syncJobTime).getStringHMS()));
|
||||
|
||||
|
||||
|
@ -533,7 +533,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
syncCardIntervalItem.setChecked(app.appConfig.registerSyncEnabled);
|
||||
syncCardIntervalItem.setOnClickAction(() -> {
|
||||
List<CharSequence> intervalNames = new ArrayList<>();
|
||||
if (App.devMode) {
|
||||
if (App.devMode && false) {
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_seconds, 30));
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_minutes, 2));
|
||||
}
|
||||
@ -545,7 +545,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_hours, 3));
|
||||
intervalNames.add(HomeFragment.plural(activity, R.plurals.time_till_hours, 4));
|
||||
List<Integer> intervals = new ArrayList<>();
|
||||
if (App.devMode) {
|
||||
if (App.devMode && false) {
|
||||
intervals.add(30);
|
||||
intervals.add(2 * 60);
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package pl.szczodrzynski.edziennik.utils
|
||||
|
||||
import android.content.Context
|
||||
import com.hypertrack.hyperlog.LogFormat
|
||||
|
||||
class DebugLogFormat(context: Context) : LogFormat(context) {
|
||||
override fun getFormattedLogMessage(logLevelName: String?, tag: String?, message: String?, timeStamp: String?, senderName: String?, osVersion: String?, deviceUUID: String?): String {
|
||||
return "${timeStamp?.replace("[TZ]".toRegex(), " ")}D/$tag: $message"
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.hypertrack.hyperlog.HyperLog;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
@ -106,15 +108,15 @@ public class Utils {
|
||||
|
||||
public static void d(String TAG, String message) {
|
||||
if (App.devMode) {
|
||||
Log.d("Szkolny/"+TAG, message);
|
||||
HyperLog.d("Szkolny/"+TAG, message);
|
||||
//debugLog.add(TAG+": "+message);
|
||||
}
|
||||
}
|
||||
public static void c(String TAG, String message) {
|
||||
if (App.devMode) {
|
||||
/*if (App.devMode) {
|
||||
Log.d(TAG, "// " + message);
|
||||
///debugLog.add(TAG+": // "+message);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,14 @@
|
||||
tools:visibility="visible"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/getLogs"
|
||||
style="@style/Widget.MaterialComponents.Button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:text="Save Debug Logs" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/librusCaptchaButton"
|
||||
style="@style/Widget.MaterialComponents.Button"
|
||||
|
@ -5,8 +5,8 @@ buildscript {
|
||||
kotlin_version = '1.3.50'
|
||||
|
||||
release = [
|
||||
versionName: "3.9.1-dev",
|
||||
versionCode: 3090100
|
||||
versionName: "3.9.2-dev",
|
||||
versionCode: 3090200
|
||||
]
|
||||
|
||||
setup = [
|
||||
|
Loading…
Reference in New Issue
Block a user