Added debug classes

This commit is contained in:
M66B 2024-05-13 17:29:36 +02:00
parent 5bc84a0482
commit a313268b1c
6 changed files with 16 additions and 12 deletions

View File

@ -118,7 +118,7 @@ class RoomTrackingLiveData<T> extends LiveData<T> {
if (isActive)
synchronized (lock) {
if (queued > 0)
eu.faircode.email.Log.persist(eu.faircode.email.EntityLog.Type.Debug,
eu.faircode.email.Log.persist(eu.faircode.email.EntityLog.Type.Debug1,
mComputeFunction + " queued=" + queued);
else {
queued++;

View File

@ -520,7 +520,7 @@ public class EmailService implements AutoCloseable {
if (auth == AUTH_TYPE_GMAIL || auth == AUTH_TYPE_OAUTH) {
try {
EntityLog.log(context, EntityLog.Type.Debug,
EntityLog.log(context, EntityLog.Type.Debug1,
ex + "\n" + android.util.Log.getStackTraceString(ex));
authenticator.refreshToken(true);
connect(dnssec, host, port, auth, user, factory);

View File

@ -65,7 +65,7 @@ public class EntityLog {
@NonNull
public String data;
public enum Type {General, Statistics, Scheduling, Network, Account, Protocol, Classification, Notification, Rules, Cloud, Debug}
public enum Type {General, Statistics, Scheduling, Network, Account, Protocol, Classification, Notification, Rules, Cloud, Debug1, Debug2, Debug3}
public static void log(final Context context, String data) {
log(context, Type.General, data);
@ -109,7 +109,7 @@ public class EntityLog {
if (context == null)
return;
if (type == Type.Debug &&
if ((type == Type.Debug1 || type == Type.Debug2 || type == Type.Debug3) &&
!(BuildConfig.DEBUG || Log.isTestRelease()))
return;
@ -233,8 +233,12 @@ public class EntityLog {
return ContextCompat.getColor(context, R.color.solarizedCyan);
case Cloud:
return ContextCompat.getColor(context, R.color.solarizedRed);
case Debug:
return Helper.resolveColor(context, R.attr.colorWarning);
case Debug1:
return ContextCompat.getColor(context, R.color.solarizedRed);
case Debug2:
return ContextCompat.getColor(context, R.color.solarizedGreen);
case Debug3:
return ContextCompat.getColor(context, R.color.solarizedBlue);
default:
return null;
}

View File

@ -24,7 +24,6 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
@ -40,6 +39,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.Group;
import androidx.lifecycle.Observer;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -203,7 +203,7 @@ public class FragmentLogs extends FragmentBase {
int len = EntityLog.Type.values().length;
if (!BuildConfig.DEBUG)
len--;
len -= 3;
SpannableStringBuilder[] titles = new SpannableStringBuilder[len];
boolean[] states = new boolean[len];

View File

@ -850,7 +850,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
@OnLifecycleEvent(Lifecycle.Event.ON_ANY)
public void onStateChanged() {
Lifecycle.State state = mowner.getLifecycle().getCurrentState();
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug, "Owner state=" + state);
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug1, "Owner state=" + state);
if (state.equals(Lifecycle.State.DESTROYED))
mowner.getLifecycle().removeObserver(this);
}
@ -872,7 +872,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
@Override
public void onChanged(boolean inCall) {
boolean suppress = prefs.getBoolean("notify_suppress_in_call", false);
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug,
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug1,
"In call=" + inCall + " suppress=" + suppress);
isInCall = (inCall && suppress);
boolean fg = Boolean.TRUE.equals(foreground.getValue());
@ -889,7 +889,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
boolean projection = (connectionState != null &&
connectionState == CarConnection.CONNECTION_TYPE_PROJECTION);
boolean suppress = prefs.getBoolean("notify_suppress_in_car", false);
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug,
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Debug1,
"Projection=" + projection + " state=" + connectionState + " suppress=" + suppress);
isInCar = (projection && suppress);
boolean fg = Boolean.TRUE.equals(foreground.getValue());

View File

@ -203,7 +203,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
LifecycleObserver watcher = new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
EntityLog.log(context, EntityLog.Type.Debug, "Owner gone task=" + name);
EntityLog.log(context, EntityLog.Type.Debug1, "Owner gone task=" + name);
destroyed = true;
onDestroyed(args);
owner.getLifecycle().removeObserver(this);