Skip to content

Commit c6bc4cf

Browse files
authored
Merge pull request #1156 from tunjid/tj/desktop-logging
Changes to enable desktop logging
2 parents 8e5ac29 + a4bdf0e commit c6bc4cf

File tree

8 files changed

+41
-15
lines changed

8 files changed

+41
-15
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
./gradlew spotlessCheck \
4343
bundleRelease \
4444
-Pheron.versionCode=${{ github.run_number }} \
45-
-Pheron.isPlayStore=true \
45+
-Pheron.isRelease=true \
4646
-Pheron.endpoint="$HERON_ENDPOINT"
4747
4848
- name: Sign AAB

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ persisted across app restarts.
125125
The following properties can be set in `~/.gradle/gradle.properties` or passed via `-P` flags.
126126
None are required for basic development builds.
127127

128-
| Property | Description |
129-
|---|---|
130-
| `heron.versionCode` | Integer version code. Managed by CI via `github.run_number`. |
131-
| `heron.endpoint` | Backend endpoint URL for the app. |
132-
| `heron.isPlayStore` | Set to `true` when building for Play Store distribution. |
133-
| `heron.releaseBranch` | Branch prefix (`bugfix/`, `feature/`, `release/`) controlling version increments. |
128+
| Property | Description |
129+
|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
130+
| `heron.versionCode` | Integer version code. Managed by CI via `github.run_number`. |
131+
| `heron.endpoint` | Backend endpoint URL for the app. |
132+
| `heron.isRelease` | Set to `true` when building release artifacts. |
133+
| `heron.releaseBranch` | Branch prefix (`bugfix/`, `feature/`, `release/`) controlling version increments. |
134134
| `heron.macOS.signing.identity` | Name of the Developer ID Application certificate in your Keychain (e.g. `Developer ID Application: Name (TEAM_ID)`). When present, the macOS DMG will be code signed. |
135135
macOS signing is only configured when `heron.macOS.signing.identity` is present,
136136
so contributors without an Apple Developer account can still build unsigned DMGs with

composeApp/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ android {
154154
}
155155
val releaseSigning = when {
156156
// Do not sign the build output, it will be signed on CI
157-
providers.gradleProperty("heron.isPlayStore").orNull.toBoolean() -> null
157+
providers.gradleProperty("heron.isRelease").orNull.toBoolean() -> null
158158
file("debugKeystore.properties").exists() -> signingConfigs.create("release") {
159159
val props = Properties()
160160
file("debugKeystore.properties")

data/logging/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ kotlin {
2727
sourceSets {
2828
commonMain {
2929
dependencies {
30+
implementation(project(":data:platform"))
3031
}
3132
}
3233
androidMain {

data/logging/src/androidMain/kotlin/com/tunjid/heron/data/logging/Logcat.android.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.tunjid.heron.data.logging
1818

1919
import android.content.Context
20+
import com.tunjid.heron.data.platform.Platform
21+
import com.tunjid.heron.data.platform.current
2022
import logcat.AndroidLogcatLogger
2123
import logcat.LogPriority as SquareLogPriority
2224
import logcat.LogcatLogger
@@ -28,12 +30,7 @@ class AndroidLogger(
2830
) : Logger {
2931

3032
override fun install() {
31-
val shouldLog = when (context.packageName.split(".").lastOrNull()?.lowercase()) {
32-
DEBUG,
33-
STAGING,
34-
-> true
35-
else -> false
36-
}
33+
val shouldLog = !Platform.current.isRelease
3734
if (!LogcatLogger.isInstalled && shouldLog) {
3835
LogcatLogger.install()
3936
LogcatLogger.loggers += AndroidLogcatLogger(SquareLogPriority.VERBOSE)

data/logging/src/desktopMain/kotlin/com/tunjid/heron/data/logging/Logcat.jvm.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616

1717
package com.tunjid.heron.data.logging
1818

19+
import com.tunjid.heron.data.platform.Platform
20+
import com.tunjid.heron.data.platform.current
1921
import logcat.LogPriority as SquareLogPriority
22+
import logcat.LogcatLogger
23+
import logcat.PrintLogger
2024
import logcat.asLog as squareAsLog
2125
import logcat.logcat as squareLogcat
2226

2327
class JvmLogger : Logger {
2428
override fun install() {
25-
// no-op on JVM
29+
val shouldLog = !Platform.current.isRelease
30+
if (!LogcatLogger.isInstalled && shouldLog) {
31+
LogcatLogger.install()
32+
LogcatLogger.loggers += PrintLogger
33+
}
2634
}
2735
}
2836

data/platform/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,26 @@
1717
plugins {
1818
id("android-library-convention")
1919
id("kotlin-library-convention")
20+
alias(libs.plugins.buildConfig)
2021
}
2122

2223
android {
2324
namespace = "com.tunjid.heron.data.platform"
2425
}
26+
27+
buildConfig {
28+
packageName("com.tunjid.heron.data.platform")
29+
30+
useKotlinOutput {
31+
internalVisibility = true
32+
}
33+
34+
forClass("Build") {
35+
buildConfigField(
36+
name = "isRelease",
37+
value = providers.gradleProperty("heron.isRelease")
38+
.map(String::toBoolean)
39+
.orElse(false),
40+
)
41+
}
42+
}

data/platform/src/commonMain/kotlin/com/tunjid/heron/data/platform/Platform.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package com.tunjid.heron.data.platform
1818

1919
interface Platform {
2020
val name: String
21+
val isRelease: Boolean
22+
get() = Build.isRelease
2123

2224
companion object
2325
}

0 commit comments

Comments
 (0)