Add logging for errors caught during hot reload

Logs composition errors while hot reload is enabled to `Log.e` on Android or `System.err` on desktop.

Fixes: 254144901
Change-Id: I948f44fb309df6ceeef737cd02e198f179441e38
diff --git a/compose/runtime/runtime/src/androidMain/kotlin/androidx/compose/runtime/ActualAndroid.android.kt b/compose/runtime/runtime/src/androidMain/kotlin/androidx/compose/runtime/ActualAndroid.android.kt
index 1c270d3..f6a03a6 100644
--- a/compose/runtime/runtime/src/androidMain/kotlin/androidx/compose/runtime/ActualAndroid.android.kt
+++ b/compose/runtime/runtime/src/androidMain/kotlin/androidx/compose/runtime/ActualAndroid.android.kt
@@ -17,6 +17,7 @@
 package androidx.compose.runtime
 
 import android.os.Looper
+import android.util.Log
 import android.view.Choreographer
 import androidx.compose.runtime.snapshots.SnapshotMutableState
 import kotlinx.coroutines.Dispatchers
@@ -90,3 +91,9 @@
     value: T,
     policy: SnapshotMutationPolicy<T>
 ): SnapshotMutableState<T> = ParcelableSnapshotMutableState(value, policy)
+
+private const val LogTag = "ComposeInternal"
+
+internal actual fun logError(message: String, e: Throwable) {
+    Log.e(LogTag, message, e)
+}
\ No newline at end of file
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt
index 986266b..d8ff0d4 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt
@@ -124,4 +124,6 @@
 @OptIn(ExperimentalComposeApi::class)
 internal expect class SnapshotContextElementImpl(
     snapshot: Snapshot
-) : SnapshotContextElement
\ No newline at end of file
+) : SnapshotContextElement
+
+internal expect fun logError(message: String, e: Throwable)
\ No newline at end of file
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
index 7da810e..6e5975c 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
@@ -639,6 +639,8 @@
     ) {
         if (_hotReloadEnabled.get() && e !is ComposeRuntimeError) {
             synchronized(stateLock) {
+                logError("Error was captured in composition while live edit was enabled.", e)
+
                 compositionsAwaitingApply.clear()
                 compositionInvalidations.clear()
                 snapshotInvalidations.clear()
diff --git a/compose/runtime/runtime/src/desktopMain/kotlin/androidx/compose/runtime/ActualDesktop.desktop.kt b/compose/runtime/runtime/src/desktopMain/kotlin/androidx/compose/runtime/ActualDesktop.desktop.kt
index 6214d94..29c9905 100644
--- a/compose/runtime/runtime/src/desktopMain/kotlin/androidx/compose/runtime/ActualDesktop.desktop.kt
+++ b/compose/runtime/runtime/src/desktopMain/kotlin/androidx/compose/runtime/ActualDesktop.desktop.kt
@@ -81,3 +81,8 @@
     value: T,
     policy: SnapshotMutationPolicy<T>
 ): SnapshotMutableState<T> = SnapshotMutableStateImpl(value, policy)
+
+internal actual fun logError(message: String, e: Throwable) {
+    System.err.println(message)
+    e.printStackTrace(System.err)
+}
\ No newline at end of file