Skip to content

Commit e1cde6e

Browse files
committed
feat(logging): name both contract packages in the log file header
1 parent d936a78 commit e1cde6e

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎libs/logging/build.gradle.kts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ dependencies {
3131
implementation(libs.androidx.annotation)
3232
implementation(libs.grpc.kotlin)
3333
implementation(project(":libs:messaging"))
34+
35+
implementation(libs.ocp.client.protocol)
36+
implementation(libs.flipcash2.client.protocol)
3437
}

‎libs/logging/src/main/kotlin/com/getcode/utils/FileTree.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.content.Context
44
import android.content.pm.PackageManager
55
import android.os.Build
66
import android.util.Log
7+
import com.codeinc.flipcash.gen.Flipcash2ContractInfo
8+
import com.codeinc.opencode.gen.OcpContractInfo
79
import kotlinx.coroutines.ExperimentalCoroutinesApi
810
import kotlinx.coroutines.channels.BufferOverflow
911
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -146,6 +148,8 @@ private fun buildDeviceHeader(context: Context): String {
146148
appendLine("=".repeat(60))
147149
appendLine("App Version: $versionName ($versionCode)")
148150
appendLine("Package: ${context.packageName}")
151+
appendLine("OCP Contract: ${OcpContractInfo.VERSION} (${OcpContractInfo.shortProtoCommit})")
152+
appendLine("FC2 Contract: ${Flipcash2ContractInfo.VERSION} (${Flipcash2ContractInfo.shortProtoCommit})")
149153
appendLine("User ID: ${userId ?: "not set"}")
150154
appendLine("Device: ${Build.MANUFACTURER} ${Build.MODEL}")
151155
appendLine("Android: ${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")

‎libs/logging/src/test/kotlin/com/getcode/utils/FileTreeTest.kt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,12 @@ class FileTreeTest {
263263
assertTrue(content.contains("Android:"))
264264
assertTrue(content.contains("Exported:"))
265265
}
266+
267+
@Test
268+
fun `exported log file names both contract packages`() {
269+
Timber.d("contract check")
270+
val content = fileTree.getLogFile()!!.readText()
271+
assertTrue(content.contains("OCP Contract:"), "header has no OCP contract line")
272+
assertTrue(content.contains("FC2 Contract:"), "header has no flipcash2 contract line")
273+
}
266274
}

0 commit comments

Comments
 (0)