Increase file logger size

This commit is contained in:
Valere 2020-04-03 13:53:34 +02:00
parent a995615f87
commit 7ffb6113a4
2 changed files with 8 additions and 6 deletions

View file

@ -25,7 +25,7 @@ Build 🧱:
-
Other changes:
-
- Increase File Logger capacities ( + use dev log preferences)
Changes in RiotX 0.18.1 (2020-03-17)
===================================================

View file

@ -35,13 +35,15 @@ 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 size20MB = 20 * 1024 * 1024
private const val size50MB = 50 * 1024 * 1024
@Singleton
class VectorFileLogger @Inject constructor(val context: Context, private val vectorPreferences: VectorPreferences) : Timber.DebugTree() {
private val maxLogSizeByte = if (vectorPreferences.labAllowedExtendedLogging()) size20MB else size50MB // 20MB
private val logRotationCount = if (vectorPreferences.labAllowedExtendedLogging()) 15 else 7
private val sLogger = Logger.getLogger("im.vector.riotx")
private var sFileHandler: FileHandler? = null
private var sCacheDirectory: File? = null
@ -61,7 +63,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 +119,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()) {