feat(logging): add total patching process duration to log data
This commit is contained in:
parent
e6cb0696d4
commit
a91d2084a4
2 changed files with 9 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ import kotlinx.serialization.json.decodeFromStream
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlin.time.Duration
|
||||
|
||||
/**
|
||||
* Central manager for storing all attempted installations and
|
||||
|
|
@ -51,6 +52,7 @@ class InstallLogManager(
|
|||
suspend fun storeInstallData(
|
||||
id: String,
|
||||
installDate: Instant,
|
||||
installDuration: Duration,
|
||||
options: PatchOptions,
|
||||
log: String,
|
||||
error: Throwable?,
|
||||
|
|
@ -60,6 +62,7 @@ class InstallLogManager(
|
|||
val data = InstallLogData(
|
||||
id = id,
|
||||
installDate = installDate,
|
||||
installDuration = installDuration,
|
||||
installOptions = options,
|
||||
environmentInfo = getEnvironmentInfo(),
|
||||
installationLog = log,
|
||||
|
|
@ -103,6 +106,7 @@ class InstallLogManager(
|
|||
data class InstallLogData(
|
||||
val id: String,
|
||||
val installDate: Instant,
|
||||
val installDuration: Duration,
|
||||
val installOptions: PatchOptions,
|
||||
val environmentInfo: String,
|
||||
val installationLog: String,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import kotlinx.coroutines.*
|
|||
import kotlinx.datetime.Clock
|
||||
import kotlinx.datetime.Instant
|
||||
import java.util.UUID
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class PatchingScreenModel(
|
||||
|
|
@ -110,6 +112,7 @@ class PatchingScreenModel(
|
|||
installLogs.storeInstallData(
|
||||
id = installId!!,
|
||||
installDate = startTime!!,
|
||||
installDuration = Duration.ZERO,
|
||||
options = options,
|
||||
log = "- Failed to initialize patch runner",
|
||||
error = error,
|
||||
|
|
@ -149,6 +152,7 @@ class PatchingScreenModel(
|
|||
installLogs.storeInstallData(
|
||||
id = installId!!,
|
||||
installDate = startTime!!,
|
||||
installDuration = runner.steps.sumOf { it.getDuration() }.milliseconds,
|
||||
options = options,
|
||||
log = runner.getLog(),
|
||||
error = null,
|
||||
|
|
@ -162,6 +166,7 @@ class PatchingScreenModel(
|
|||
installLogs.storeInstallData(
|
||||
id = installId!!,
|
||||
installDate = startTime!!,
|
||||
installDuration = runner.steps.sumOf { it.getDuration() }.milliseconds,
|
||||
options = options,
|
||||
log = runner.getLog(),
|
||||
error = error,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue