Loading app/src/main/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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> Loading app/src/main/java/foundation/e/drive/EdriveApplication.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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"); Loading app/src/main/java/foundation/e/drive/activity/AccountsActivity.java +4 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 = Loading @@ -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()); Loading Loading @@ -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 { Loading @@ -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)); Loading app/src/main/java/foundation/e/drive/receivers/DebugCmdReceiver.java +8 −1 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -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"); Loading @@ -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; } Loading app/src/main/java/foundation/e/drive/utils/ReleaseTree.java 0 → 100644 +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
app/src/main/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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> Loading
app/src/main/java/foundation/e/drive/EdriveApplication.java +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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"); Loading
app/src/main/java/foundation/e/drive/activity/AccountsActivity.java +4 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 = Loading @@ -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()); Loading Loading @@ -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 { Loading @@ -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)); Loading
app/src/main/java/foundation/e/drive/receivers/DebugCmdReceiver.java +8 −1 Original line number Diff line number Diff line Loading @@ -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; /** Loading @@ -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"); Loading @@ -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; } Loading
app/src/main/java/foundation/e/drive/utils/ReleaseTree.java 0 → 100644 +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; } } }