diff --git a/CHANGES.md b/CHANGES.md index 6340889573..de4d914d59 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,7 +26,7 @@ Build 🧱: - Other changes: - - + - Increase File Logger capacities ( + use dev log preferences) Changes in RiotX 0.18.1 (2020-03-17) =================================================== diff --git a/vector/src/main/java/im/vector/riotx/features/rageshake/VectorFileLogger.kt b/vector/src/main/java/im/vector/riotx/features/rageshake/VectorFileLogger.kt index 16e231491a..8dba018067 100644 --- a/vector/src/main/java/im/vector/riotx/features/rageshake/VectorFileLogger.kt +++ b/vector/src/main/java/im/vector/riotx/features/rageshake/VectorFileLogger.kt @@ -35,13 +35,25 @@ import java.util.logging.Logger import javax.inject.Inject import javax.inject.Singleton -private const val LOG_SIZE_BYTES = 20 * 1024 * 1024 // 20MB - -private const val LOG_ROTATION_COUNT = 3 +private const val SIZE_20MB = 20 * 1024 * 1024 +private const val SIZE_50MB = 50 * 1024 * 1024 @Singleton class VectorFileLogger @Inject constructor(val context: Context, private val vectorPreferences: VectorPreferences) : Timber.DebugTree() { + private val maxLogSizeByte: Int + private val logRotationCount: Int + + init { + if (vectorPreferences.labAllowedExtendedLogging()) { + maxLogSizeByte = SIZE_50MB + logRotationCount = 15 + } else { + maxLogSizeByte = SIZE_20MB + logRotationCount = 7 + } + } + private val sLogger = Logger.getLogger("im.vector.riotx") private var sFileHandler: FileHandler? = null private var sCacheDirectory: File? = null @@ -61,7 +73,7 @@ class VectorFileLogger @Inject constructor(val context: Context, private val vec setLogDirectory(File(logsDirectoryFile)) try { if (sCacheDirectory != null) { - sFileHandler = FileHandler(sCacheDirectory!!.absolutePath + "/" + sFileName + ".%g.txt", LOG_SIZE_BYTES, LOG_ROTATION_COUNT) + sFileHandler = FileHandler(sCacheDirectory!!.absolutePath + "/" + sFileName + ".%g.txt", maxLogSizeByte, logRotationCount) sFileHandler?.formatter = LogFormatter() sLogger.useParentHandlers = false sLogger.level = Level.ALL @@ -117,7 +129,7 @@ class VectorFileLogger @Inject constructor(val context: Context, private val vec sFileHandler!!.flush() val absPath = sCacheDirectory?.absolutePath ?: return emptyList() - for (i in 0..LOG_ROTATION_COUNT) { + for (i in 0..logRotationCount) { val filepath = "$absPath/$sFileName.$i.txt" val file = File(filepath) if (file.exists()) {