1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2781 Tech | Measure command execution time (#1508)

Co-authored-by: Evgenii Kozlov <ubuphobos@gmail.com>
This commit is contained in:
Konstantin Ivanov 2024-08-27 18:56:30 +02:00 committed by konstantiniiv
parent 67cae7e841
commit 2f70b950bc
3 changed files with 527 additions and 528 deletions

View file

@ -47,7 +47,7 @@ android {
buildConfigField "boolean", "USE_NEW_WINDOW_INSET_API", "true"
buildConfigField "boolean", "USE_EDGE_TO_EDGE", "true"
buildConfigField "boolean", "LOG_FROM_MW_LIBRARY", localProperties.getProperty("LOG_FROM_MW_LIBRARY", "false")
buildConfigField "boolean", "LOG_MW_INTERACTION", localProperties.getProperty("LOG_MW_INTERACTION", "false")
buildConfigField "boolean", "LOG_MW_INTERACTION", localProperties.getProperty("LOG_MW_INTERACTION", "true")
buildConfigField "boolean", "LOG_DASHBOARD_REDUCER", localProperties.getProperty("LOG_DASHBOARD_REDUCER", "false")
buildConfigField "boolean", "LOG_EDITOR_VIEWMODEL_EVENTS", localProperties.getProperty("LOG_EDITOR_VIEWMODEL_EVENTS", "false")
buildConfigField "boolean", "LOG_EDITOR_CONTROL_PANEL", localProperties.getProperty("LOG_EDITOR_CONTROL_PANEL", "false")

View file

@ -3,6 +3,8 @@ package com.anytypeio.anytype.middleware.interactor
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
import timber.log.Timber
import javax.inject.Inject
import kotlin.time.Duration
import kotlin.time.DurationUnit
interface MiddlewareProtobufLogger {
@ -10,6 +12,8 @@ interface MiddlewareProtobufLogger {
fun logResponse(any: Any)
fun logResponse(any: Any, time: Duration?)
fun logEvent(any: Any)
class Impl @Inject constructor(
@ -29,6 +33,12 @@ interface MiddlewareProtobufLogger {
}
}
override fun logResponse(any: Any, time: Duration?) {
Timber.d("response -> ${any.toLogMessage()} [${time.format()}ms] ")
}
private fun Duration?.format(): Long? = this?.toLong(DurationUnit.MILLISECONDS)
override fun logEvent(any: Any) {
if (featureToggles.isLogMiddlewareInteraction) {
Timber.d("event -> ${any.toLogMessage()}")