diff --git a/client/android/src/org/amnezia/vpn/AmneziaActivity.kt b/client/android/src/org/amnezia/vpn/AmneziaActivity.kt index 2adda8ef..fb314d3f 100644 --- a/client/android/src/org/amnezia/vpn/AmneziaActivity.kt +++ b/client/android/src/org/amnezia/vpn/AmneziaActivity.kt @@ -453,7 +453,7 @@ class AmneziaActivity : QtActivity() { @Suppress("unused") fun setSaveLogs(enabled: Boolean) { - Log.d(TAG, "Set save logs: $enabled") + Log.v(TAG, "Set save logs: $enabled") mainScope.launch { Log.saveLogs = enabled vpnServiceMessenger.send { @@ -473,7 +473,9 @@ class AmneziaActivity : QtActivity() { @Suppress("unused") fun clearLogs() { Log.v(TAG, "Clear logs") - Log.clearLogs() + mainScope.launch { + Log.clearLogs() + } } @Suppress("unused") diff --git a/client/android/utils/src/main/kotlin/Log.kt b/client/android/utils/src/main/kotlin/Log.kt index 03da4507..a656b9ea 100644 --- a/client/android/utils/src/main/kotlin/Log.kt +++ b/client/android/utils/src/main/kotlin/Log.kt @@ -109,9 +109,11 @@ object Log { "${deviceInfo()}\n${readLogs()}\nLOGCAT:\n${getLogcat()}" fun clearLogs() { - withLock { - logFile.delete() - rotateLogFile.delete() + if (logDir.exists()) { + withLock { + logFile.delete() + rotateLogFile.delete() + } } } diff --git a/client/ui/controllers/settingsController.cpp b/client/ui/controllers/settingsController.cpp index 077214cf..24ed311c 100644 --- a/client/ui/controllers/settingsController.cpp +++ b/client/ui/controllers/settingsController.cpp @@ -77,8 +77,6 @@ void SettingsController::toggleLogging(bool enable) AmneziaVPN::toggleLogging(enable); #endif if (enable == true) { - checkIfNeedDisableLogs(); - qInfo().noquote() << QString("Logging has enabled on %1 version %2 %3").arg(APPLICATION_NAME, APP_VERSION, GIT_COMMIT_HASH); qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName(), QSysInfo::currentCpuArchitecture()); } @@ -216,10 +214,12 @@ bool SettingsController::isCameraPresent() void SettingsController::checkIfNeedDisableLogs() { - m_loggingDisableDate = m_settings->getLogEnableDate().addDays(14); - if (m_loggingDisableDate <= QDateTime::currentDateTime()) { - toggleLogging(false); - clearLogs(); - emit loggingDisableByWatcher(); + if (m_settings->isSaveLogs()) { + m_loggingDisableDate = m_settings->getLogEnableDate().addDays(14); + if (m_loggingDisableDate <= QDateTime::currentDateTime()) { + toggleLogging(false); + clearLogs(); + emit loggingDisableByWatcher(); + } } }