From 61589b1eb44c5186a77c5a8f92d9ff78cb682397 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 23 Feb 2023 16:53:08 +0100 Subject: [PATCH 1/2] Limit log sent to sentry to ERROR only and change log priority for some cases --- .../e/drive/services/ObserverService.java | 4 ++-- .../drive/services/SynchronizationService.java | 18 +++++++++--------- .../foundation/e/drive/utils/ReleaseTree.java | 2 +- .../e/drive/work/CreateRemoteFolderWorker.java | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/services/ObserverService.java b/app/src/main/java/foundation/e/drive/services/ObserverService.java index 46b351bf..d166bd1d 100644 --- a/app/src/main/java/foundation/e/drive/services/ObserverService.java +++ b/app/src/main/java/foundation/e/drive/services/ObserverService.java @@ -201,13 +201,13 @@ public class ObserverService extends Service implements OnRemoteOperationListene Timber.i("deleteOldestCrashLogs()"); final File externalFilesDir = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER); if (externalFilesDir == null) { - Timber.e("getExternalFilesDir() returned null. Preventing a NPE"); + Timber.d("getExternalFilesDir() returned null. Preventing a NPE"); return; } final File[] fileToRemove = externalFilesDir.listFiles(new CrashlogsFileFilter()); if (fileToRemove == null) { - Timber.e("getExternalFilesDir() returned null. Preventing a NPE"); + Timber.d("getExternalFilesDir() returned null. Preventing a NPE"); return; } diff --git a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java index 0eaa40ff..b7d50f7b 100644 --- a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java +++ b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java @@ -297,38 +297,38 @@ public class SynchronizationService extends Service implements OnRemoteOperation break; case SYNC_CONFLICT: //Case specific to UploadFileOperation - Timber.e("%s : Sync_conflict : File is already up to date", operationClassName); + Timber.d("%s : Sync_conflict : File is already up to date", operationClassName); break; case INVALID_OVERWRITE: - Timber.e("%s => invalid_overwrite :\n remote file and local file doesn't have the same size", operationClassName); + Timber.d("%s => invalid_overwrite :\n remote file and local file doesn't have the same size", operationClassName); break; case UNKNOWN_ERROR: if (callerOperation instanceof UploadFileOperation) { final int rowAffected = DbHelper.forceFoldertoBeRescan(((UploadFileOperation) callerOperation).getSyncedState().getId(), getApplicationContext()); - Timber.e("Upload failed for unknown reason.\n Force folder to be rescan next time (row affected) : %s", rowAffected); + Timber.d("Upload failed for unknown reason.\n Force folder to be rescan next time (row affected) : %s", rowAffected); } else if (callerOperation instanceof DownloadFileOperation) { - Timber.e("Download: Unknown_error : failed"); + Timber.d("Download: Unknown_error : failed"); } break; case FORBIDDEN: if (callerOperation instanceof UploadFileOperation) { final int rowAffected = DbHelper.forceFoldertoBeRescan(((UploadFileOperation) callerOperation).getSyncedState().getId(), getApplicationContext()); - Timber.e("Upload: Forbidden : Can't get syncedFileState, no remote path defined. Force folder to be rescan next time (row affected) : %s", rowAffected); + Timber.d("Upload: Forbidden : Can't get syncedFileState, no remote path defined. Force folder to be rescan next time (row affected) : %s", rowAffected); } else if (callerOperation instanceof DownloadFileOperation) { - Timber.e("Download : Forbidden: Can't get syncedFileState, no local path defined"); + Timber.d("Download : Forbidden: Can't get syncedFileState, no local path defined"); } break; case QUOTA_EXCEEDED: //Case specific to UploadFileOperation - Timber.w("Quota_EXCEEDED"); + Timber.d("Quota_EXCEEDED"); break; case FILE_NOT_FOUND: //Case specific to DownloadFileOperation - Timber.e("%s : File_not_found: File not found after download", operationClassName); + Timber.d("%s : File_not_found: File not found after download", operationClassName); break; case ETAG_UNCHANGED: //Case specific to DownloadFileOperation - Timber.e("%s : Sync_conflict: File is already up to date", operationClassName); + Timber.d("%s : Sync_conflict: File is already up to date", operationClassName); break; } } diff --git a/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java b/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java index dbc19e12..656f96a2 100644 --- a/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java +++ b/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java @@ -31,7 +31,7 @@ public class ReleaseTree extends Timber.DebugTree{ return; } - if (priority >= Log.WARN) { + if (priority == Log.ERROR) { Telemetry.INSTANCE.reportMessage(tag + " " + message); } diff --git a/app/src/main/java/foundation/e/drive/work/CreateRemoteFolderWorker.java b/app/src/main/java/foundation/e/drive/work/CreateRemoteFolderWorker.java index 28005199..e112c0f3 100644 --- a/app/src/main/java/foundation/e/drive/work/CreateRemoteFolderWorker.java +++ b/app/src/main/java/foundation/e/drive/work/CreateRemoteFolderWorker.java @@ -60,7 +60,7 @@ public class CreateRemoteFolderWorker extends Worker { final Context context = getApplicationContext(); final Account account = getAccount(); if (account == null) { - Timber.e("doWork(): Can't get valid account"); + Timber.d("doWork(): Can't get valid account"); return Result.failure(); } -- GitLab From 0c4be86578ff96b0ef86826413eb7f01ccceea3e Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 23 Feb 2023 17:05:34 +0100 Subject: [PATCH 2/2] Renable logging for warning priority change logging priority for lots of 'warning' Remove SynchronizationService onLowMemory, because it's already present in EdriveApplication --- .../foundation/e/drive/EdriveApplication.java | 2 +- .../FileObservers/FileEventListener.java | 2 +- .../e/drive/services/InitializerService.java | 7 +++--- .../e/drive/services/ObserverService.java | 24 +++++++++---------- .../services/SynchronizationService.java | 8 +------ .../foundation/e/drive/utils/ReleaseTree.java | 2 +- .../e/drive/work/LocalFileDeleter.java | 4 ++-- 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/EdriveApplication.java b/app/src/main/java/foundation/e/drive/EdriveApplication.java index 0ba43320..5346c468 100644 --- a/app/src/main/java/foundation/e/drive/EdriveApplication.java +++ b/app/src/main/java/foundation/e/drive/EdriveApplication.java @@ -98,6 +98,6 @@ public class EdriveApplication extends Application { @Override public void onLowMemory() { super.onLowMemory(); - Timber.w("System is low on memory. Application might get killed by the system."); + Timber.i("System is low on memory. Application might get killed by the system."); } } diff --git a/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java b/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java index 57c342c8..77c55b36 100644 --- a/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java +++ b/app/src/main/java/foundation/e/drive/FileObservers/FileEventListener.java @@ -184,7 +184,7 @@ public class FileEventListener { final String parentPath = CommonUtils.getLocalPath(file.getParentFile()); SyncedFolder parentFolder = DbHelper.getSyncedFolderByLocalPath(parentPath, appContext); if (parentFolder == null || !parentFolder.isEnabled()) { - Timber.w("Won't send sync request: no parent are known for new file: %s", file.getName()); + Timber.d("Won't send sync request: no parent are known for new file: %s", file.getName()); return; } int scannableValue = 0; diff --git a/app/src/main/java/foundation/e/drive/services/InitializerService.java b/app/src/main/java/foundation/e/drive/services/InitializerService.java index 6b310f49..7c0e0738 100644 --- a/app/src/main/java/foundation/e/drive/services/InitializerService.java +++ b/app/src/main/java/foundation/e/drive/services/InitializerService.java @@ -63,7 +63,7 @@ public class InitializerService extends Service { SharedPreferences prefs = this.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); if (prefs.getBoolean(AppConstants.INITIALIZATION_HAS_BEEN_DONE, false)) { - Timber.w("Initializer has already been done"); + Timber.i("Initializer has already been done"); } else { String accountName = prefs.getString(AccountManager.KEY_ACCOUNT_NAME, ""); String accountType = prefs.getString(AccountManager.KEY_ACCOUNT_TYPE, ""); @@ -79,16 +79,15 @@ public class InitializerService extends Service { } if (accountName.isEmpty()) { - Timber.w("Account's name not found"); + Timber.d("Account's name not found"); stopSelf(); } else { this.account = CommonUtils.getAccount(accountName, accountType, AccountManager.get(this)); - //Get OwnCloudlient if (this.account != null) { this.cloudClient = DavClientProvider.getInstance().getClientInstance(account, getApplicationContext()); start(); } else { - Timber.w("Got account is invalid"); + Timber.i("Got account is invalid"); stopSelf(); } } diff --git a/app/src/main/java/foundation/e/drive/services/ObserverService.java b/app/src/main/java/foundation/e/drive/services/ObserverService.java index d166bd1d..5664eb1c 100644 --- a/app/src/main/java/foundation/e/drive/services/ObserverService.java +++ b/app/src/main/java/foundation/e/drive/services/ObserverService.java @@ -103,7 +103,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene @Override public int onStartCommand(Intent intent, int flags, int startId) { - Timber.i("onStartCommand(%s)", startId); + Timber.v("onStartCommand(%s)", startId); CommonUtils.setServiceUnCaughtExceptionHandler(this); @@ -134,27 +134,27 @@ public class ObserverService extends Service implements OnRemoteOperationListene * @return false if at least one condition is false */ private boolean checkStartCondition(final SharedPreferences prefs, final boolean forcedSync) { - Timber.d("checkStartCondition()"); + Timber.v("checkStartCondition()"); if (mAccount == null) { - Timber.w("No account registered"); + Timber.d("No account registered"); return false; } if (!CommonUtils.isMediaSyncEnabled(mAccount) && !CommonUtils.isSettingsSyncEnabled(mAccount)) { - Timber.w("Synchronization has been disabled in account's settings"); + Timber.d("Synchronization has been disabled in account's settings"); return false; } if (!prefs.getBoolean(INITIALIZATION_HAS_BEEN_DONE, false)) { - Timber.w("Initialization hasn't been done"); + Timber.d("Initialization hasn't been done"); Intent initializerIntent = new Intent(this, InitializerService.class); startService(initializerIntent); return false; } if (isWorking) { - Timber.w("ObserverService is already working"); + Timber.d("ObserverService is already working"); return false; } @@ -164,14 +164,14 @@ public class ObserverService extends Service implements OnRemoteOperationListene final long lastSyncTime = prefs.getLong(AppConstants.KEY_LAST_SYNC_TIME, 0L); final long currentTime = System.currentTimeMillis(); if (!forcedSync && (currentTime - lastSyncTime ) < INTERSYNC_MINIMUM_DELAY ) { - Timber.w("Delay between now and last call is too short"); + Timber.d("Delay between now and last call is too short"); return false; } final boolean meteredNetworkAllowed = CommonUtils.isMeteredNetworkAllowed(mAccount); //check for the case where intent has been launched by initializerService if (!CommonUtils.haveNetworkConnection(this, meteredNetworkAllowed)) { - Timber.w("There is no allowed internet connexion."); + Timber.d("There is no allowed internet connexion."); return false; } @@ -249,7 +249,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene this.mSyncedFolders = loadSyncedFolders(); if (mSyncedFolders.isEmpty()) { - Timber.w("List of synced folders is empty"); + Timber.d("List of synced folders is empty"); this.stopSelf(); return; } @@ -257,7 +257,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene if (remote) { final OwnCloudClient client = DavClientProvider.getInstance().getClientInstance(mAccount, getApplicationContext()); if (client == null) { - Timber.w("OwnCloudClient is null"); + Timber.d("OwnCloudClient is null"); return; } @@ -305,7 +305,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene if (!(operation instanceof ListFileRemoteOperation)) return; if (!result.isSuccess()) { - Timber.w("ListRemoteFileOperation failed. Http code: %s", result.getHttpCode()); + Timber.d("ListRemoteFileOperation failed. Http code: %s", result.getHttpCode()); } final List remoteFiles = ((RemoteOperationResult>)result).getResultData(); @@ -333,7 +333,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene Timber.d("syncRequests contains %s", syncRequests.size()); passSyncRequestsToSynchronizationService(); } else { - Timber.w("There is no file to sync."); + Timber.i("There is no file to sync."); getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE) .edit() .putLong(AppConstants.KEY_LAST_SYNC_TIME, System.currentTimeMillis()) diff --git a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java index b7d50f7b..2ff8733b 100644 --- a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java +++ b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java @@ -82,7 +82,7 @@ public class SynchronizationService extends Service implements OnRemoteOperation account = CommonUtils.getAccount(accountName, accountType, AccountManager.get(this)); if (account == null) { - Timber.w("No account available"); + Timber.d("No account available"); stopSelf(); return START_NOT_STICKY; } @@ -113,12 +113,6 @@ public class SynchronizationService extends Service implements OnRemoteOperation return binder; } - @Override - public void onLowMemory() { - Timber.w("System is low on memory. Service might get killed."); - } - - /** * Try to pause synchronization. * Can only be paused if no sync is already running and no request queue is started diff --git a/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java b/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java index 656f96a2..dbc19e12 100644 --- a/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java +++ b/app/src/main/java/foundation/e/drive/utils/ReleaseTree.java @@ -31,7 +31,7 @@ public class ReleaseTree extends Timber.DebugTree{ return; } - if (priority == Log.ERROR) { + if (priority >= Log.WARN) { Telemetry.INSTANCE.reportMessage(tag + " " + message); } diff --git a/app/src/main/java/foundation/e/drive/work/LocalFileDeleter.java b/app/src/main/java/foundation/e/drive/work/LocalFileDeleter.java index f6178551..df8e0ad8 100644 --- a/app/src/main/java/foundation/e/drive/work/LocalFileDeleter.java +++ b/app/src/main/java/foundation/e/drive/work/LocalFileDeleter.java @@ -47,7 +47,7 @@ public class LocalFileDeleter { if (file.exists()) { try { if (!file.delete()) { - Timber.w("local file ( %s ) removal failed", file.getName()); + Timber.d("local file ( %s ) removal failed", file.getName()); return false; } } catch (SecurityException exception) { @@ -62,7 +62,7 @@ public class LocalFileDeleter { if (DbHelper.manageSyncedFileStateDB(fileState, "DELETE", context) <= 0) { - Timber.e("Failed to remove %s from DB", file.getName()); + Timber.d("Failed to remove %s from DB", file.getName()); } return true; } -- GitLab