Timber.d instead of Timber.v
This commit is contained in:
parent
5edf7ca520
commit
1d1f78a020
@ -65,7 +65,7 @@ internal class FileInitialSyncStatusRepository(directory: File) : InitialSyncSta
|
|||||||
val state = cache?.step ?: InitialSyncStatus.STEP_INIT
|
val state = cache?.step ?: InitialSyncStatus.STEP_INIT
|
||||||
return if (state >= InitialSyncStatus.STEP_DOWNLOADED
|
return if (state >= InitialSyncStatus.STEP_DOWNLOADED
|
||||||
&& System.currentTimeMillis() > (cache?.downloadedDate ?: 0) + INIT_SYNC_FILE_LIFETIME) {
|
&& System.currentTimeMillis() > (cache?.downloadedDate ?: 0) + INIT_SYNC_FILE_LIFETIME) {
|
||||||
Timber.v("INIT_SYNC downloaded file is outdated, download it again")
|
Timber.d("INIT_SYNC downloaded file is outdated, download it again")
|
||||||
// The downloaded file is outdated
|
// The downloaded file is outdated
|
||||||
setStep(InitialSyncStatus.STEP_INIT)
|
setStep(InitialSyncStatus.STEP_INIT)
|
||||||
InitialSyncStatus.STEP_INIT
|
InitialSyncStatus.STEP_INIT
|
||||||
|
@ -147,13 +147,13 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
|
|||||||
if (numberOfChunks > 1) {
|
if (numberOfChunks > 1) {
|
||||||
reportSubtask(reporter, InitSyncStep.ImportingAccountJoinedRooms, numberOfChunks, 0.6f) {
|
reportSubtask(reporter, InitSyncStep.ImportingAccountJoinedRooms, numberOfChunks, 0.6f) {
|
||||||
val chunkSize = listSize / numberOfChunks
|
val chunkSize = listSize / numberOfChunks
|
||||||
Timber.v("INIT_SYNC $listSize rooms to insert, split into $numberOfChunks sublists of $chunkSize items")
|
Timber.d("INIT_SYNC $listSize rooms to insert, split into $numberOfChunks sublists of $chunkSize items")
|
||||||
// I cannot find a better way to chunk a map, so chunk the keys and then create new maps
|
// I cannot find a better way to chunk a map, so chunk the keys and then create new maps
|
||||||
handlingStrategy.data.keys
|
handlingStrategy.data.keys
|
||||||
.chunked(chunkSize)
|
.chunked(chunkSize)
|
||||||
.forEachIndexed { index, roomIds ->
|
.forEachIndexed { index, roomIds ->
|
||||||
val roomEntities = roomIds
|
val roomEntities = roomIds
|
||||||
.also { Timber.v("INIT_SYNC insert ${roomIds.size} rooms") }
|
.also { Timber.d("INIT_SYNC insert ${roomIds.size} rooms") }
|
||||||
.map {
|
.map {
|
||||||
handleJoinedRoom(
|
handleJoinedRoom(
|
||||||
realm = realm,
|
realm = realm,
|
||||||
|
@ -101,7 +101,7 @@ internal class DefaultSyncTask @Inject constructor(
|
|||||||
val readTimeOut = (params.timeout + TIMEOUT_MARGIN).coerceAtLeast(TimeOutInterceptor.DEFAULT_LONG_TIMEOUT)
|
val readTimeOut = (params.timeout + TIMEOUT_MARGIN).coerceAtLeast(TimeOutInterceptor.DEFAULT_LONG_TIMEOUT)
|
||||||
|
|
||||||
if (isInitialSync) {
|
if (isInitialSync) {
|
||||||
Timber.v("INIT_SYNC with filter: ${requestParams["filter"]}")
|
Timber.d("INIT_SYNC with filter: ${requestParams["filter"]}")
|
||||||
val initSyncStrategy = initialSyncStrategy
|
val initSyncStrategy = initialSyncStrategy
|
||||||
logDuration("INIT_SYNC strategy: $initSyncStrategy") {
|
logDuration("INIT_SYNC strategy: $initSyncStrategy") {
|
||||||
if (initSyncStrategy is InitialSyncStrategy.Optimized) {
|
if (initSyncStrategy is InitialSyncStrategy.Optimized) {
|
||||||
@ -145,7 +145,7 @@ internal class DefaultSyncTask @Inject constructor(
|
|||||||
val workingFile = File(workingDir, "initSync.json")
|
val workingFile = File(workingDir, "initSync.json")
|
||||||
val status = initialSyncStatusRepository.getStep()
|
val status = initialSyncStatusRepository.getStep()
|
||||||
if (workingFile.exists() && status >= InitialSyncStatus.STEP_DOWNLOADED) {
|
if (workingFile.exists() && status >= InitialSyncStatus.STEP_DOWNLOADED) {
|
||||||
Timber.v("INIT_SYNC file is already here")
|
Timber.d("INIT_SYNC file is already here")
|
||||||
reportSubtask(initialSyncProgressService, InitSyncStep.Downloading, 1, 0.3f) {
|
reportSubtask(initialSyncProgressService, InitSyncStep.Downloading, 1, 0.3f) {
|
||||||
// Empty task
|
// Empty task
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ internal class DefaultSyncTask @Inject constructor(
|
|||||||
// Log some stats
|
// Log some stats
|
||||||
val nbOfJoinedRooms = syncResponse.rooms?.join?.size ?: 0
|
val nbOfJoinedRooms = syncResponse.rooms?.join?.size ?: 0
|
||||||
val nbOfJoinedRoomsInFile = syncResponse.rooms?.join?.values?.count { it.ephemeral is LazyRoomSyncEphemeral.Stored }
|
val nbOfJoinedRoomsInFile = syncResponse.rooms?.join?.values?.count { it.ephemeral is LazyRoomSyncEphemeral.Stored }
|
||||||
Timber.v("INIT_SYNC $nbOfJoinedRooms rooms, $nbOfJoinedRoomsInFile ephemeral stored into files")
|
Timber.d("INIT_SYNC $nbOfJoinedRooms rooms, $nbOfJoinedRoomsInFile ephemeral stored into files")
|
||||||
|
|
||||||
logDuration("INIT_SYNC Database insertion") {
|
logDuration("INIT_SYNC Database insertion") {
|
||||||
syncResponseHandler.handleResponse(syncResponse, null, initialSyncProgressService)
|
syncResponseHandler.handleResponse(syncResponse, null, initialSyncProgressService)
|
||||||
|
@ -57,12 +57,12 @@ internal class SplitLazyRoomSyncEphemeralJsonAdapter(
|
|||||||
}
|
}
|
||||||
val limit = syncStrategy.minSizeToStoreInFile
|
val limit = syncStrategy.minSizeToStoreInFile
|
||||||
return if (json.length > limit) {
|
return if (json.length > limit) {
|
||||||
Timber.v("INIT_SYNC $path content length: ${json.length} copy to a file")
|
Timber.d("INIT_SYNC $path content length: ${json.length} copy to a file")
|
||||||
// Copy the source to a file
|
// Copy the source to a file
|
||||||
roomSyncEphemeralTemporaryStore.write(roomId, json)
|
roomSyncEphemeralTemporaryStore.write(roomId, json)
|
||||||
LazyRoomSyncEphemeral.Stored
|
LazyRoomSyncEphemeral.Stored
|
||||||
} else {
|
} else {
|
||||||
Timber.v("INIT_SYNC $path content length: ${json.length} parse it now")
|
Timber.d("INIT_SYNC $path content length: ${json.length} parse it now")
|
||||||
val roomSync = delegate.fromJson(json) ?: return null
|
val roomSync = delegate.fromJson(json) ?: return null
|
||||||
LazyRoomSyncEphemeral.Parsed(roomSync)
|
LazyRoomSyncEphemeral.Parsed(roomSync)
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ internal class InitialSyncResponseParser @Inject constructor(
|
|||||||
|
|
||||||
fun parse(syncStrategy: InitialSyncStrategy.Optimized, workingFile: File): SyncResponse {
|
fun parse(syncStrategy: InitialSyncStrategy.Optimized, workingFile: File): SyncResponse {
|
||||||
val syncResponseLength = workingFile.length().toInt()
|
val syncResponseLength = workingFile.length().toInt()
|
||||||
Timber.v("INIT_SYNC Sync file size is $syncResponseLength bytes")
|
Timber.d("INIT_SYNC Sync file size is $syncResponseLength bytes")
|
||||||
val shouldSplit = syncResponseLength >= syncStrategy.minSizeToSplit
|
val shouldSplit = syncResponseLength >= syncStrategy.minSizeToSplit
|
||||||
Timber.v("INIT_SYNC should split in several files: $shouldSplit")
|
Timber.d("INIT_SYNC should split in several files: $shouldSplit")
|
||||||
return getMoshi(syncStrategy, shouldSplit)
|
return getMoshi(syncStrategy, shouldSplit)
|
||||||
.adapter(SyncResponse::class.java)
|
.adapter(SyncResponse::class.java)
|
||||||
.fromJson(workingFile.source().buffer())!!
|
.fromJson(workingFile.source().buffer())!!
|
||||||
|
@ -33,13 +33,13 @@ internal fun <T> Collection<T>.logLimit(maxQuantity: Int = 5): String {
|
|||||||
|
|
||||||
internal suspend fun <T> logDuration(message: String,
|
internal suspend fun <T> logDuration(message: String,
|
||||||
block: suspend () -> T): T {
|
block: suspend () -> T): T {
|
||||||
Timber.v("$message -- BEGIN")
|
Timber.d("$message -- BEGIN")
|
||||||
val start = System.currentTimeMillis()
|
val start = System.currentTimeMillis()
|
||||||
val result = logRamUsage(message) {
|
val result = logRamUsage(message) {
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
val duration = System.currentTimeMillis() - start
|
val duration = System.currentTimeMillis() - start
|
||||||
Timber.v("$message -- END duration: $duration ms")
|
Timber.d("$message -- END duration: $duration ms")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -50,12 +50,12 @@ internal suspend fun <T> logRamUsage(message: String, block: suspend () -> T): T
|
|||||||
runtime.gc()
|
runtime.gc()
|
||||||
val freeMemoryInMb = runtime.freeMemory() / 1048576L
|
val freeMemoryInMb = runtime.freeMemory() / 1048576L
|
||||||
val usedMemInMBStart = runtime.totalMemory() / 1048576L - freeMemoryInMb
|
val usedMemInMBStart = runtime.totalMemory() / 1048576L - freeMemoryInMb
|
||||||
Timber.v("$message -- BEGIN (free memory: $freeMemoryInMb MB)")
|
Timber.d("$message -- BEGIN (free memory: $freeMemoryInMb MB)")
|
||||||
val result = block()
|
val result = block()
|
||||||
runtime.gc()
|
runtime.gc()
|
||||||
val usedMemInMBEnd = (runtime.totalMemory() - runtime.freeMemory()) / 1048576L
|
val usedMemInMBEnd = (runtime.totalMemory() - runtime.freeMemory()) / 1048576L
|
||||||
val usedMemInMBDiff = usedMemInMBEnd - usedMemInMBStart
|
val usedMemInMBDiff = usedMemInMBEnd - usedMemInMBStart
|
||||||
Timber.v("$message -- END RAM usage: $usedMemInMBDiff MB")
|
Timber.d("$message -- END RAM usage: $usedMemInMBDiff MB")
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
block()
|
block()
|
||||||
|
Loading…
Reference in New Issue
Block a user