Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0776c6b9 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Merge branch '660-o-p4-move-to-timber' into '660-o-set-Logger-to-info-for-prod'

660 o p4 move to timber

See merge request !167
parents 8c23f1bb e37fba80
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@
            <intent-filter>
                <action android:name="foundation.e.drive.action.FORCE_SYNC" />
                <action android:name="foundation.e.drive.action.DUMP_DATABASE"/>
                <action android:name="foundation.e.drive.action.FULL_LOG_ON_PROD"/>
            </intent-filter>
        </receiver>
    </application>
+2 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import foundation.e.drive.database.FailedSyncPrefsManager;
import foundation.e.drive.services.SynchronizationService;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.ReleaseTree;
import timber.log.Timber;
import static timber.log.Timber.DebugTree;

@@ -43,7 +44,7 @@ public class EdriveApplication extends Application {
            Timber.plant(new DebugTree());
        } else {
            //Not handled yet
            //Timber.plant(new ReleaseTree());
            Timber.plant(new ReleaseTree());
        }
        Timber.tag("EdriveApplication");

+4 −4
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;
@@ -38,9 +37,9 @@ import foundation.e.drive.databinding.ActivityAccountsBinding;
import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.DavClientProvider;
import foundation.e.drive.widgets.EDriveWidget;
import timber.log.Timber;

public class AccountsActivity extends AppCompatActivity {
    private static final String TAG = AccountsActivity.class.getSimpleName();

    public static final String NON_OFFICIAL_AVATAR_PATH = "/index.php/avatar/";
    private static final String ACCOUNT_SETTINGS =
@@ -51,6 +50,7 @@ public class AccountsActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Timber.tag(AccountsActivity.class.getSimpleName());
        binding = ActivityAccountsBinding.inflate(getLayoutInflater());

        setContentView(binding.getRoot());
@@ -98,7 +98,7 @@ public class AccountsActivity extends AppCompatActivity {
                totalShownQuota = CommonUtils.humanReadableByteCountBin(totalQuotaLong);
            }
        } catch (NumberFormatException ignored) {
            Log.i(TAG, "Bad totalQuotaLong " + totalQuota);
            Timber.i("Bad totalQuotaLong " + totalQuota);
        }

        try {
@@ -107,7 +107,7 @@ public class AccountsActivity extends AppCompatActivity {
                usedShownQuota = CommonUtils.humanReadableByteCountBin(usedQuotaLong);
            }
        } catch (NumberFormatException ignore) {
            Log.i(TAG, "Bad usedQuotaLong " + usedQuota);
            Timber.i("Bad usedQuotaLong " + usedQuota);
        }

        binding.plan.setText(getString(R.string.free_plan, totalShownQuota));
+8 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import android.util.Log;

import foundation.e.drive.database.DbHelper;
import foundation.e.drive.services.ObserverService;
import foundation.e.drive.utils.ReleaseTree;
import timber.log.Timber;

/**
@@ -24,7 +25,8 @@ public class DebugCmdReceiver extends BroadcastReceiver {

    public static final String ACTION_FORCE_SYNC = "foundation.e.drive.action.FORCE_SYNC";
    public static final String ACTION_DUMP_DATABASE = "foundation.e.drive.action.DUMP_DATABASE";

    public static final String ACTION_FULL_LOG_ON_PROD = "foundation.e.drive.action.FULL_LOG_ON_PROD";
    private static final String FULL_LOG_ENABLE_KEY = "full_log_enable";
    @Override
    public void onReceive(Context context, Intent intent) {
        Timber.tag(DebugCmdReceiver.class.getSimpleName()).v("onReceive");
@@ -37,6 +39,11 @@ public class DebugCmdReceiver extends BroadcastReceiver {
                Timber.d("Dump database intent received");
                DbHelper.dumpDatabase(context);
                break;
            case ACTION_FULL_LOG_ON_PROD:
                final boolean allow_full_log = intent.getBooleanExtra(FULL_LOG_ENABLE_KEY, false);
                ReleaseTree.allowDebugLogOnProd(allow_full_log);
                Timber.d("Allow full log on prod: %s", allow_full_log);
                break;
            default:
                break;
        }
+43 −0
Original line number Diff line number Diff line
package foundation.e.drive.utils;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import timber.log.Timber;

public class ReleaseTree extends Timber.Tree {
    private static boolean debugEnable = false;

    public static void allowDebugLogOnProd(boolean allow) {
        debugEnable = allow;
    }

    @Override
    protected void log(int priority, @Nullable String tag, @NonNull String message, @Nullable Throwable throwable) {
        if (!debugEnable && priority < Log.INFO ) {
            return;
        }
        switch (priority) {
            case Log.VERBOSE:
                Log.v(tag, message, throwable);
                break;
            case Log.DEBUG:
                Log.d(tag, message, throwable);
                break;
            case Log.INFO:
                Log.i(tag, message, throwable);
                break;
            case Log.WARN:
                Log.w(tag, message, throwable);
                break;
            case Log.ERROR:
                Log.w(tag, message, throwable);
                break;
            case Log.ASSERT:
                Log.wtf(tag, message, throwable);
                break;
        }
    }
}
Loading