From 802e2bfcb71d419fe80fd909fe4001638dc60d70 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Wed, 16 Oct 2024 08:15:43 -0400 Subject: [PATCH 01/15] Rolling log file writer in new io module --- gradle/libs.versions.toml | 6 +- kermit-io/build.gradle.kts | 100 +++++++++++ .../kermit/io/RollingFileLogWriter.kt | 169 ++++++++++++++++++ .../kermit/io/RollingFileLogWriterConfig.kt | 22 +++ settings.gradle.kts | 3 +- 5 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 kermit-io/build.gradle.kts create mode 100644 kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt create mode 100644 kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6771ca50..cccf41f8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,6 +30,8 @@ koin-core = "3.5.3" koin-android = "3.5.3" koin-test = "3.5.3" coroutines = "1.7.3" +kotlinx-datetime = "0.6.1" +kotlinx-io = "0.5.4" roboelectric = "4.10.3" buildConfig = "4.1.2" mavenPublish = "0.27.0" @@ -61,6 +63,8 @@ testhelp = { module = "co.touchlab:testhelp", version.ref = "testhelp" } koin = { module = "io.insert-koin:koin-core", version.ref = "koin-core" } koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin-android" } coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } +kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" } roboelectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" } koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin-test" } @@ -90,4 +94,4 @@ android = [ "androidx-navigationFragment", "androidx-navigationUI", "androidx-coordinatorLayout", -] \ No newline at end of file +] diff --git a/kermit-io/build.gradle.kts b/kermit-io/build.gradle.kts new file mode 100644 index 00000000..8d7c9376 --- /dev/null +++ b/kermit-io/build.gradle.kts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("com.android.library") + kotlin("multiplatform") + id("com.vanniktech.maven.publish") +} + +kotlin { + androidTarget { + publishAllLibraryVariants() + } + jvm() + + macosX64() + macosArm64() + iosX64() + iosArm64() + iosSimulatorArm64() + watchosArm32() + watchosArm64() + watchosSimulatorArm64() + watchosDeviceArm64() + watchosX64() + tvosArm64() + tvosSimulatorArm64() + tvosX64() + + mingwX64() + linuxX64() + linuxArm64() + + androidNativeArm32() + androidNativeArm64() + androidNativeX86() + androidNativeX64() + + @Suppress("OPT_IN_USAGE") + applyDefaultHierarchyTemplate { + common { + group("commonJvm") { + withAndroidTarget() + withJvm() + } + } + } + + sourceSets { + commonMain.dependencies { + implementation(project(":kermit-core")) + + implementation(libs.kotlinx.datetime) + implementation(libs.kotlinx.io) + implementation(libs.coroutines) + } + + commonTest.dependencies { + implementation(kotlin("test")) + implementation(project(":kermit-test")) + } + + getByName("commonJvmTest").dependencies { + implementation(kotlin("test-junit")) + } + + getByName("androidUnitTest").dependencies { + implementation(libs.androidx.runner) + implementation(libs.roboelectric) + } + } +} + +android { + namespace = "co.touchlab.kermit.io" + compileSdk = libs.versions.compileSdk.get().toInt() + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +tasks.withType { + kotlinOptions.jvmTarget = "1.8" +} diff --git a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt new file mode 100644 index 00000000..ef69e540 --- /dev/null +++ b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermit.io + +import co.touchlab.kermit.* +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.trySendBlocking +import kotlinx.datetime.Clock +import kotlinx.datetime.format +import kotlinx.datetime.format.DateTimeComponents +import kotlinx.io.* +import kotlinx.io.files.FileSystem +import kotlinx.io.files.Path +import kotlinx.io.files.SystemFileSystem + +/** + * Implements a log writer that writes log messages to a rolling file. + * + * It also deletes old log files when the maximum number of log files is reached. We simply keep + * approximately [RollingFileLogWriterConfig.rollOnSize] bytes in each log file, + * and delete the oldest file when we have more than [RollingFileLogWriterConfig.maxLogFiles]. + * + * Formatting is governed by the passed [MessageStringFormatter], but we do prepend a timestamp by default. + * Turn this off via [RollingFileLogWriterConfig.prependTimestamp] + * + * Writes to the file are done by a different coroutine. The main reason for this is to make writes to the + * log file sink thread-safe, and so that file rolling can be performed without additional synchronization + * or locking. The channel that buffers log messages is currently unbuffered, so logging threads will block + * until the I/O is complete. However, buffering could easily be introduced to potentially increase logging + * throughput. The envisioned usage scenarios for this class probably do not warrant this. + * + * The recommended way to obtain the logPath on Android is: + * + * ```kotlin + * Path(context.filesDir.path) + * ``` + * + * and on iOS this wil return the application's sandboxed document directory: + * + * ```kotlin + * (NSFileManager.defaultManager.URLsForDirectory(NSDocumentDirectory, NSUserDomainMask).last() as NSURL).path!! + * ``` + * + * However, you can use any path that is writable by the application. This would generally be implemented by + * platform-specific code. + */ +open class RollingFileLogWriter( + private val messageStringFormatter: MessageStringFormatter = DefaultFormatter, + private val config: RollingFileLogWriterConfig, + private val clock: Clock = Clock.System, + private val fileSystem: FileSystem = SystemFileSystem, +) : LogWriter() { + @OptIn(DelicateCoroutinesApi::class, ExperimentalCoroutinesApi::class) + private val coroutineScope = CoroutineScope( + newSingleThreadContext("RollingFileLogWriter") + + SupervisorJob() + + CoroutineName("RollingFileLogWriter") + + CoroutineExceptionHandler { _, throwable -> + // can't log it, we're the logger -- print to standard error + println("RollingFileLogWriter: Uncaught exception in writer coroutine") + throwable.printStackTrace() + } + ) + + private val loggingChannel: Channel = Channel() + + init { + coroutineScope.launch { + writer() + } + } + + override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { + bufferLog( + formatMessage( + severity = severity, + tag = Tag(tag), + message = Message(message) + ), throwable + ) + } + + private fun bufferLog(message: String, throwable: Throwable?) { + val log = buildString { + append(clock.now().format(DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET)) + append(" ") + appendLine(message) + if (throwable != null) { + appendLine(throwable.stackTraceToString()) + } + } + loggingChannel.trySendBlocking(Buffer().apply { writeString(log) }) + } + + private fun formatMessage(severity: Severity, tag: Tag?, message: Message): String = + messageStringFormatter.formatMessage(severity, if (config.logTag) tag else null, message) + + private fun maybeRollLogs(size: Long): Boolean { + return if (size > config.rollOnSize) { + rollLogs() + true + } else false + } + + private fun rollLogs() { + if (fileSystem.exists(pathForLogIndex(config.maxLogFiles - 1))) { + fileSystem.delete(pathForLogIndex(config.maxLogFiles - 1)) + } + (0..<(config.maxLogFiles - 1)).reversed().forEach { + val sourcePath = pathForLogIndex(it) + val targetPath = pathForLogIndex(it + 1) + if (fileSystem.exists(sourcePath)) { + try { + fileSystem.atomicMove(sourcePath, targetPath) + } catch (e: IOException) { + // we can't log it, we're the logger -- print to standard error + println("RollingFileLogWriter: Failed to roll log file $sourcePath to $targetPath (sourcePath exists=${fileSystem.exists(sourcePath)})") + e.printStackTrace() + } + } + } + } + + private fun pathForLogIndex(index: Int): Path = + Path(config.logPath, if (index == 0) "${config.logPrefix}.log" else "${config.logPrefix}-$index.log") + + private suspend fun writer() { + val logFilePath = pathForLogIndex(0) + + if (fileSystem.exists(logFilePath)) { + maybeRollLogs(fileSizeOrZero(logFilePath)) + } + + fun createNewLogSink(): Sink = fileSystem + .sink(logFilePath, append = true) + .buffered() + + var currentLogSink: Sink = createNewLogSink() + + while (currentCoroutineContext().isActive) { + // wait for data to be available, flush periodically + val result = loggingChannel.receiveCatching() + + // check if logs need rolling + val rolled = maybeRollLogs(fileSizeOrZero(logFilePath)) + if (rolled) { + currentLogSink.close() + currentLogSink = createNewLogSink() + } + + result.getOrNull()?.transferTo(currentLogSink) + + // we could improve performance by flushing less frequently at the cost of potential data loss, + // but this is a safe default + currentLogSink.flush() + } + } + + private fun fileSizeOrZero(path: Path) = fileSystem.metadataOrNull(path)?.size ?: 0 +} diff --git a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt new file mode 100644 index 00000000..d62b1b8e --- /dev/null +++ b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermit.io + +import kotlinx.io.files.Path + +data class RollingFileLogWriterConfig( + val logPrefix: String, + val logPath: Path, + val rollOnSize: Long = 10 * 1024 * 1024, // 10MB + val maxLogFiles: Int = 5, + val logTag: Boolean = true, + val prependTimestamp: Boolean = true, +) diff --git a/settings.gradle.kts b/settings.gradle.kts index c3e5a345..26f6e610 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,7 @@ */ include(":kermit-core") include(":kermit") +include(":kermit-io") include(":kermit-simple") include(":kermit-test") @@ -38,4 +39,4 @@ pluginManagement { gradlePluginPortal() mavenCentral() } -} \ No newline at end of file +} From 258a11789944cd1c1ce1186ce15838604137ea44 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 13:09:02 -0500 Subject: [PATCH 02/15] initial changes --- kermit-io/api/android/kermit-io.api | 28 +++++++++++++++++++ kermit-io/api/jvm/kermit-io.api | 28 +++++++++++++++++++ kermit-io/build.gradle.kts | 4 +-- .../kermit/io/RollingFileLogWriter.kt | 2 +- .../co/touchlab/KermitSample/FirstFragment.kt | 2 +- .../co/touchlab/kermitsample/LogWriter.kt | 14 ++++++++++ .../co/touchlab/kermitsample/LogWriter.kt | 14 ++++++++++ .../co/touchlab/kermitsample/SampleCommon.kt | 3 +- .../kotlin/co/touchlab/kermitsample/Test.kt | 14 ++++++++++ 9 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 kermit-io/api/android/kermit-io.api create mode 100644 kermit-io/api/jvm/kermit-io.api create mode 100644 samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt create mode 100644 samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt create mode 100644 samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt diff --git a/kermit-io/api/android/kermit-io.api b/kermit-io/api/android/kermit-io.api new file mode 100644 index 00000000..4557a3a0 --- /dev/null +++ b/kermit-io/api/android/kermit-io.api @@ -0,0 +1,28 @@ +public class co/touchlab/kermit/io/RollingFileLogWriter : co/touchlab/kermit/LogWriter { + public fun (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Lco/touchlab/kermit/MessageStringFormatter;Lkotlinx/datetime/Clock;Lkotlinx/io/files/FileSystem;)V + public synthetic fun (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Lco/touchlab/kermit/MessageStringFormatter;Lkotlinx/datetime/Clock;Lkotlinx/io/files/FileSystem;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun log (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V +} + +public final class co/touchlab/kermit/io/RollingFileLogWriterConfig { + public fun (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZ)V + public synthetic fun (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Lkotlinx/io/files/Path; + public final fun component3 ()J + public final fun component4 ()I + public final fun component5 ()Z + public final fun component6 ()Z + public final fun copy (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZ)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; + public static synthetic fun copy$default (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Ljava/lang/String;Lkotlinx/io/files/Path;JIZZILjava/lang/Object;)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; + public fun equals (Ljava/lang/Object;)Z + public final fun getLogPath ()Lkotlinx/io/files/Path; + public final fun getLogPrefix ()Ljava/lang/String; + public final fun getLogTag ()Z + public final fun getMaxLogFiles ()I + public final fun getPrependTimestamp ()Z + public final fun getRollOnSize ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/kermit-io/api/jvm/kermit-io.api b/kermit-io/api/jvm/kermit-io.api new file mode 100644 index 00000000..4557a3a0 --- /dev/null +++ b/kermit-io/api/jvm/kermit-io.api @@ -0,0 +1,28 @@ +public class co/touchlab/kermit/io/RollingFileLogWriter : co/touchlab/kermit/LogWriter { + public fun (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Lco/touchlab/kermit/MessageStringFormatter;Lkotlinx/datetime/Clock;Lkotlinx/io/files/FileSystem;)V + public synthetic fun (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Lco/touchlab/kermit/MessageStringFormatter;Lkotlinx/datetime/Clock;Lkotlinx/io/files/FileSystem;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun log (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V +} + +public final class co/touchlab/kermit/io/RollingFileLogWriterConfig { + public fun (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZ)V + public synthetic fun (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Lkotlinx/io/files/Path; + public final fun component3 ()J + public final fun component4 ()I + public final fun component5 ()Z + public final fun component6 ()Z + public final fun copy (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZ)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; + public static synthetic fun copy$default (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Ljava/lang/String;Lkotlinx/io/files/Path;JIZZILjava/lang/Object;)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; + public fun equals (Ljava/lang/Object;)Z + public final fun getLogPath ()Lkotlinx/io/files/Path; + public final fun getLogPrefix ()Ljava/lang/String; + public final fun getLogTag ()Z + public final fun getMaxLogFiles ()I + public final fun getPrependTimestamp ()Z + public final fun getRollOnSize ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/kermit-io/build.gradle.kts b/kermit-io/build.gradle.kts index 8d7c9376..79d21a2b 100644 --- a/kermit-io/build.gradle.kts +++ b/kermit-io/build.gradle.kts @@ -62,8 +62,8 @@ kotlin { commonMain.dependencies { implementation(project(":kermit-core")) - implementation(libs.kotlinx.datetime) - implementation(libs.kotlinx.io) + api(libs.kotlinx.datetime) + api(libs.kotlinx.io) implementation(libs.coroutines) } diff --git a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt index ef69e540..cce33225 100644 --- a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt +++ b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt @@ -54,8 +54,8 @@ import kotlinx.io.files.SystemFileSystem * platform-specific code. */ open class RollingFileLogWriter( - private val messageStringFormatter: MessageStringFormatter = DefaultFormatter, private val config: RollingFileLogWriterConfig, + private val messageStringFormatter: MessageStringFormatter = DefaultFormatter, private val clock: Clock = Clock.System, private val fileSystem: FileSystem = SystemFileSystem, ) : LogWriter() { diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 47228420..1a34457e 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleCommon() + val sample = SampleCommon() // context?.filesDir?.path ?: "" val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt new file mode 100644 index 00000000..b79fccf2 --- /dev/null +++ b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermitsample + +class AndroidLogWriter : LogWriter { +} \ No newline at end of file diff --git a/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt b/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt new file mode 100644 index 00000000..fb736e6b --- /dev/null +++ b/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermitsample + +interface LogWriter { +} \ No newline at end of file diff --git a/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/SampleCommon.kt b/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/SampleCommon.kt index 07bd40e3..8719d13a 100644 --- a/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/SampleCommon.kt +++ b/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/SampleCommon.kt @@ -12,8 +12,9 @@ package co.touchlab.kermitsample import co.touchlab.kermit.Logger -class SampleCommon { +open class SampleCommon { private var count = 0 + fun onClickI() { count++ Logger.i { "Common click count: $count" } diff --git a/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt new file mode 100644 index 00000000..cdaa8872 --- /dev/null +++ b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermitsample + +class iOSLogWriter : LogWriter { +} \ No newline at end of file From f73e029627c2be8e189c1644c9f635b8419362c1 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 13:09:42 -0500 Subject: [PATCH 03/15] Update build.gradle.kts --- samples/sample/shared/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 92de0620..9d3c7673 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -59,9 +59,13 @@ kotlin { implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } + androidMain.dependencies { + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + } iosMain.dependencies { // Only if you want to talk to Kermit from Swift api("co.touchlab:kermit-simple:${KERMIT_VERSION}") + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } } cocoapods { From 72e210f1531b917fc2e24d74aa62427ed2c3b2f7 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 14:18:07 -0500 Subject: [PATCH 04/15] Finalizing sample --- kermit-io/api/android/kermit-io.api | 4 +-- kermit-io/api/jvm/kermit-io.api | 4 +-- .../kermit/io/RollingFileLogWriter.kt | 2 +- .../kermit/io/RollingFileLogWriterConfig.kt | 4 +-- .../KermitSampleIOS/ContentView.swift | 17 ++++++++++-- samples/sample/KermitSampleIOS/Podfile.lock | 4 +-- .../co/touchlab/KermitSample/FirstFragment.kt | 4 +-- samples/sample/shared/build.gradle.kts | 27 +++++++++++++------ .../co/touchlab/kermitsample/LogWriter.kt | 14 ---------- .../kotlin/co/touchlab/kermitsample/Test.kt | 14 ---------- .../co/touchlab/kermitsample/SampleMobile.kt} | 17 +++++++++++- 11 files changed, 61 insertions(+), 50 deletions(-) delete mode 100644 samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt delete mode 100644 samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt rename samples/sample/shared/src/{androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt => mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt} (52%) diff --git a/kermit-io/api/android/kermit-io.api b/kermit-io/api/android/kermit-io.api index 4557a3a0..b4918998 100644 --- a/kermit-io/api/android/kermit-io.api +++ b/kermit-io/api/android/kermit-io.api @@ -16,8 +16,8 @@ public final class co/touchlab/kermit/io/RollingFileLogWriterConfig { public final fun copy (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZ)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; public static synthetic fun copy$default (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Ljava/lang/String;Lkotlinx/io/files/Path;JIZZILjava/lang/Object;)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; public fun equals (Ljava/lang/Object;)Z - public final fun getLogPath ()Lkotlinx/io/files/Path; - public final fun getLogPrefix ()Ljava/lang/String; + public final fun getLogFileName ()Ljava/lang/String; + public final fun getLogFilePath ()Lkotlinx/io/files/Path; public final fun getLogTag ()Z public final fun getMaxLogFiles ()I public final fun getPrependTimestamp ()Z diff --git a/kermit-io/api/jvm/kermit-io.api b/kermit-io/api/jvm/kermit-io.api index 4557a3a0..b4918998 100644 --- a/kermit-io/api/jvm/kermit-io.api +++ b/kermit-io/api/jvm/kermit-io.api @@ -16,8 +16,8 @@ public final class co/touchlab/kermit/io/RollingFileLogWriterConfig { public final fun copy (Ljava/lang/String;Lkotlinx/io/files/Path;JIZZ)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; public static synthetic fun copy$default (Lco/touchlab/kermit/io/RollingFileLogWriterConfig;Ljava/lang/String;Lkotlinx/io/files/Path;JIZZILjava/lang/Object;)Lco/touchlab/kermit/io/RollingFileLogWriterConfig; public fun equals (Ljava/lang/Object;)Z - public final fun getLogPath ()Lkotlinx/io/files/Path; - public final fun getLogPrefix ()Ljava/lang/String; + public final fun getLogFileName ()Ljava/lang/String; + public final fun getLogFilePath ()Lkotlinx/io/files/Path; public final fun getLogTag ()Z public final fun getMaxLogFiles ()I public final fun getPrependTimestamp ()Z diff --git a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt index cce33225..e97e66cd 100644 --- a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt +++ b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriter.kt @@ -131,7 +131,7 @@ open class RollingFileLogWriter( } private fun pathForLogIndex(index: Int): Path = - Path(config.logPath, if (index == 0) "${config.logPrefix}.log" else "${config.logPrefix}-$index.log") + Path(config.logFilePath, if (index == 0) "${config.logFileName}.log" else "${config.logFileName}-$index.log") private suspend fun writer() { val logFilePath = pathForLogIndex(0) diff --git a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt index d62b1b8e..5ce242a3 100644 --- a/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt +++ b/kermit-io/src/commonMain/kotlin/co/touchlab/kermit/io/RollingFileLogWriterConfig.kt @@ -13,8 +13,8 @@ package co.touchlab.kermit.io import kotlinx.io.files.Path data class RollingFileLogWriterConfig( - val logPrefix: String, - val logPath: Path, + val logFileName: String, + val logFilePath: Path, val rollOnSize: Long = 10 * 1024 * 1024, // 10MB val maxLogFiles: Int = 5, val logTag: Boolean = true, diff --git a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift index 912b01aa..56cdb73e 100644 --- a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift +++ b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift @@ -15,10 +15,23 @@ import shared struct ContentView: View { - let common: SampleCommon + let common: SampleMobile init() { - self.common = SampleCommon() + let filePath = NSHomeDirectory() + "/Documents/" + let fileName = "KermitSampleLogs" + ContentView.createLoggingFile(withName: fileName, atPath: filePath) + + self.common = SampleMobile(filePathString: filePath, logFileName: fileName) + } + + private static func createLoggingFile(withName name:String, atPath filePath: String){ + let absouluteFilePath = "\(filePath)\(name).log" + if (FileManager.default.createFile(atPath: absouluteFilePath, contents: nil, attributes: nil)) { + print("File created successfully.") + } else { + print("File not created.") + } } var body: some View { diff --git a/samples/sample/KermitSampleIOS/Podfile.lock b/samples/sample/KermitSampleIOS/Podfile.lock index eb34e809..c1dd52e2 100644 --- a/samples/sample/KermitSampleIOS/Podfile.lock +++ b/samples/sample/KermitSampleIOS/Podfile.lock @@ -9,8 +9,8 @@ EXTERNAL SOURCES: :path: "../shared" SPEC CHECKSUMS: - shared: 317794cafa8cc02021e4c781c7235ace20c9dfdc + shared: 983dc25845ffd9786066f42f1d094f72b41f2e37 PODFILE CHECKSUM: eb18a5a396ff91b77d2f3b607dba9c4cf5f57893 -COCOAPODS: 1.12.1 +COCOAPODS: 1.15.2 diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 1a34457e..116e8c6a 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -15,7 +15,7 @@ import android.view.View import androidx.fragment.app.Fragment import co.touchlab.KermitSample.databinding.FragmentFirstBinding import co.touchlab.kermit.Logger -import co.touchlab.kermitsample.SampleCommon +import co.touchlab.kermitsample.SampleMobile /** * A simple [Fragment] subclass as the default destination in the navigation. @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleCommon() // context?.filesDir?.path ?: "" + val sample = SampleMobile(context?.filesDir?.path ?: "") val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 9d3c7673..fa485c04 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -51,21 +51,32 @@ kotlin { sourceSets { commonMain.dependencies { - implementation("co.touchlab:kermit:${KERMIT_VERSION}") + implementation("co.touchlab:kermit:2.0.7") } commonTest.dependencies { implementation(kotlin("test")) - implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") + implementation("co.touchlab:kermit-test:2.0.7") } - androidMain.dependencies { - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + val mobileMain by creating { + dependsOn(commonMain.get()) + dependencies { + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + } } - iosMain.dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + androidMain { + dependsOn(mobileMain) + } + iosMain { + dependsOn(mobileMain) + iosX64Main.get().dependsOn(this) + iosArm64Main.get().dependsOn(this) + iosSimulatorArm64Main.get().dependsOn(this) + dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") + } } } cocoapods { diff --git a/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt b/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt deleted file mode 100644 index fb736e6b..00000000 --- a/samples/sample/shared/src/commonMain/kotlin/co/touchlab/kermitsample/LogWriter.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2024 Touchlab - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ - -package co.touchlab.kermitsample - -interface LogWriter { -} \ No newline at end of file diff --git a/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt deleted file mode 100644 index cdaa8872..00000000 --- a/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/Test.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2024 Touchlab - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ - -package co.touchlab.kermitsample - -class iOSLogWriter : LogWriter { -} \ No newline at end of file diff --git a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt similarity index 52% rename from samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt rename to samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt index b79fccf2..297bfd7a 100644 --- a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/LogWriter.kt +++ b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -10,5 +10,20 @@ package co.touchlab.kermitsample -class AndroidLogWriter : LogWriter { +import co.touchlab.kermit.Logger +import co.touchlab.kermit.io.RollingFileLogWriter +import co.touchlab.kermit.io.RollingFileLogWriterConfig +import kotlinx.io.files.Path + +class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { + init { + Logger.addLogWriter( + RollingFileLogWriter( + config = RollingFileLogWriterConfig( + logFileName = logFileName, + logFilePath = Path(filePathString), + ) + ) + ) + } } \ No newline at end of file From 5bc6226081dc2b7840f6cc4a267378c7ef84e574 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 14:26:41 -0500 Subject: [PATCH 05/15] reverting datetime as it may cause conflicts with versions --- kermit-io/build.gradle.kts | 2 +- samples/sample/shared/build.gradle.kts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kermit-io/build.gradle.kts b/kermit-io/build.gradle.kts index 79d21a2b..c4c8152d 100644 --- a/kermit-io/build.gradle.kts +++ b/kermit-io/build.gradle.kts @@ -62,7 +62,7 @@ kotlin { commonMain.dependencies { implementation(project(":kermit-core")) - api(libs.kotlinx.datetime) + implementation(libs.kotlinx.datetime) api(libs.kotlinx.io) implementation(libs.coroutines) } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index fa485c04..bbc706be 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -62,6 +62,7 @@ kotlin { val mobileMain by creating { dependsOn(commonMain.get()) dependencies { + implementation(libs.kotlinx.datetime) implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } } From eca1b28fa47073ccc1f5bdd53f9c57a0c3050fe2 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 14:29:52 -0500 Subject: [PATCH 06/15] Update build.gradle.kts --- samples/sample/shared/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index bbc706be..d13d3741 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -51,13 +51,13 @@ kotlin { sourceSets { commonMain.dependencies { - implementation("co.touchlab:kermit:2.0.7") + implementation("co.touchlab:kermit:${KERMIT_VERSION}") } commonTest.dependencies { implementation(kotlin("test")) - implementation("co.touchlab:kermit-test:2.0.7") + implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } val mobileMain by creating { dependsOn(commonMain.get()) From 9e01d3451ac68866f4f3f01bf0635ce88fedb873 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 14:55:00 -0500 Subject: [PATCH 07/15] reverting to api --- kermit-io/build.gradle.kts | 2 +- samples/sample/shared/build.gradle.kts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/kermit-io/build.gradle.kts b/kermit-io/build.gradle.kts index c4c8152d..79d21a2b 100644 --- a/kermit-io/build.gradle.kts +++ b/kermit-io/build.gradle.kts @@ -62,7 +62,7 @@ kotlin { commonMain.dependencies { implementation(project(":kermit-core")) - implementation(libs.kotlinx.datetime) + api(libs.kotlinx.datetime) api(libs.kotlinx.io) implementation(libs.coroutines) } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index d13d3741..76957897 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -62,7 +62,6 @@ kotlin { val mobileMain by creating { dependsOn(commonMain.get()) dependencies { - implementation(libs.kotlinx.datetime) implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } } From 1c97ee62b358a551e84427f5f9321b21fa72de2f Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 16:29:06 -0500 Subject: [PATCH 08/15] Removing Logger from sample --- .../KermitSampleIOS/ContentView.swift | 4 +-- .../co/touchlab/KermitSample/FirstFragment.kt | 4 +-- samples/sample/shared/build.gradle.kts | 21 ++------------ .../co/touchlab/kermitsample/SampleMobile.kt | 29 ------------------- 4 files changed, 7 insertions(+), 51 deletions(-) delete mode 100644 samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt diff --git a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift index 56cdb73e..c18af835 100644 --- a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift +++ b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift @@ -15,14 +15,14 @@ import shared struct ContentView: View { - let common: SampleMobile + let common: CommonMobile init() { let filePath = NSHomeDirectory() + "/Documents/" let fileName = "KermitSampleLogs" ContentView.createLoggingFile(withName: fileName, atPath: filePath) - self.common = SampleMobile(filePathString: filePath, logFileName: fileName) + self.common = CommonMobile() } private static func createLoggingFile(withName name:String, atPath filePath: String){ diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 116e8c6a..47228420 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -15,7 +15,7 @@ import android.view.View import androidx.fragment.app.Fragment import co.touchlab.KermitSample.databinding.FragmentFirstBinding import co.touchlab.kermit.Logger -import co.touchlab.kermitsample.SampleMobile +import co.touchlab.kermitsample.SampleCommon /** * A simple [Fragment] subclass as the default destination in the navigation. @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleMobile(context?.filesDir?.path ?: "") + val sample = SampleCommon() val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 76957897..92de0620 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -59,24 +59,9 @@ kotlin { implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - val mobileMain by creating { - dependsOn(commonMain.get()) - dependencies { - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") - } - } - androidMain { - dependsOn(mobileMain) - } - iosMain { - dependsOn(mobileMain) - iosX64Main.get().dependsOn(this) - iosArm64Main.get().dependsOn(this) - iosSimulatorArm64Main.get().dependsOn(this) - dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } + iosMain.dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") } } cocoapods { diff --git a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt deleted file mode 100644 index 297bfd7a..00000000 --- a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2024 Touchlab - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ - -package co.touchlab.kermitsample - -import co.touchlab.kermit.Logger -import co.touchlab.kermit.io.RollingFileLogWriter -import co.touchlab.kermit.io.RollingFileLogWriterConfig -import kotlinx.io.files.Path - -class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { - init { - Logger.addLogWriter( - RollingFileLogWriter( - config = RollingFileLogWriterConfig( - logFileName = logFileName, - logFilePath = Path(filePathString), - ) - ) - ) - } -} \ No newline at end of file From 6ea15aba7ad23cbb01102f86e2ae2214c01b6f07 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 16:49:34 -0500 Subject: [PATCH 09/15] Revert "Removing Logger from sample" This reverts commit 1c97ee62b358a551e84427f5f9321b21fa72de2f. --- .../KermitSampleIOS/ContentView.swift | 4 +-- .../co/touchlab/KermitSample/FirstFragment.kt | 4 +-- samples/sample/shared/build.gradle.kts | 21 ++++++++++++-- .../co/touchlab/kermitsample/SampleMobile.kt | 29 +++++++++++++++++++ 4 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt diff --git a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift index c18af835..56cdb73e 100644 --- a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift +++ b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift @@ -15,14 +15,14 @@ import shared struct ContentView: View { - let common: CommonMobile + let common: SampleMobile init() { let filePath = NSHomeDirectory() + "/Documents/" let fileName = "KermitSampleLogs" ContentView.createLoggingFile(withName: fileName, atPath: filePath) - self.common = CommonMobile() + self.common = SampleMobile(filePathString: filePath, logFileName: fileName) } private static func createLoggingFile(withName name:String, atPath filePath: String){ diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 47228420..116e8c6a 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -15,7 +15,7 @@ import android.view.View import androidx.fragment.app.Fragment import co.touchlab.KermitSample.databinding.FragmentFirstBinding import co.touchlab.kermit.Logger -import co.touchlab.kermitsample.SampleCommon +import co.touchlab.kermitsample.SampleMobile /** * A simple [Fragment] subclass as the default destination in the navigation. @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleCommon() + val sample = SampleMobile(context?.filesDir?.path ?: "") val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 92de0620..76957897 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -59,9 +59,24 @@ kotlin { implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - iosMain.dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") + val mobileMain by creating { + dependsOn(commonMain.get()) + dependencies { + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + } + } + androidMain { + dependsOn(mobileMain) + } + iosMain { + dependsOn(mobileMain) + iosX64Main.get().dependsOn(this) + iosArm64Main.get().dependsOn(this) + iosSimulatorArm64Main.get().dependsOn(this) + dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") + } } } cocoapods { diff --git a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt new file mode 100644 index 00000000..297bfd7a --- /dev/null +++ b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermitsample + +import co.touchlab.kermit.Logger +import co.touchlab.kermit.io.RollingFileLogWriter +import co.touchlab.kermit.io.RollingFileLogWriterConfig +import kotlinx.io.files.Path + +class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { + init { + Logger.addLogWriter( + RollingFileLogWriter( + config = RollingFileLogWriterConfig( + logFileName = logFileName, + logFilePath = Path(filePathString), + ) + ) + ) + } +} \ No newline at end of file From f7a799b8aca37d46a6d96425e15c62c235f313ad Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 17:00:59 -0500 Subject: [PATCH 10/15] Splitting versions for mobile --- .../KermitSampleIOS/ContentView.swift | 4 +-- .../co/touchlab/KermitSample/FirstFragment.kt | 4 +-- samples/sample/shared/build.gradle.kts | 23 ++++----------- .../co/touchlab/kermitsample/SampleMobile.kt | 29 +++++++++++++++++++ .../co/touchlab/kermitsample/SampleMobile.kt | 2 +- 5 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt rename samples/sample/shared/src/{mobileMain => iosMain}/kotlin/co/touchlab/kermitsample/SampleMobile.kt (91%) diff --git a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift index 56cdb73e..7ce2b0df 100644 --- a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift +++ b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift @@ -15,14 +15,14 @@ import shared struct ContentView: View { - let common: SampleMobile + let common: SampleIOS init() { let filePath = NSHomeDirectory() + "/Documents/" let fileName = "KermitSampleLogs" ContentView.createLoggingFile(withName: fileName, atPath: filePath) - self.common = SampleMobile(filePathString: filePath, logFileName: fileName) + self.common = SampleIOS(filePathString: filePath, logFileName: fileName) } private static func createLoggingFile(withName name:String, atPath filePath: String){ diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 116e8c6a..362a6cc8 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -15,7 +15,7 @@ import android.view.View import androidx.fragment.app.Fragment import co.touchlab.KermitSample.databinding.FragmentFirstBinding import co.touchlab.kermit.Logger -import co.touchlab.kermitsample.SampleMobile +import co.touchlab.kermitsample.SampleAndroid /** * A simple [Fragment] subclass as the default destination in the navigation. @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleMobile(context?.filesDir?.path ?: "") + val sample = SampleAndroid(context?.filesDir?.path ?: "") val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 76957897..9d3c7673 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -59,24 +59,13 @@ kotlin { implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - val mobileMain by creating { - dependsOn(commonMain.get()) - dependencies { - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") - } + androidMain.dependencies { + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } - androidMain { - dependsOn(mobileMain) - } - iosMain { - dependsOn(mobileMain) - iosX64Main.get().dependsOn(this) - iosArm64Main.get().dependsOn(this) - iosSimulatorArm64Main.get().dependsOn(this) - dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } + iosMain.dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } } cocoapods { diff --git a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt new file mode 100644 index 00000000..5df98418 --- /dev/null +++ b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermitsample + +import co.touchlab.kermit.Logger +import co.touchlab.kermit.io.RollingFileLogWriter +import co.touchlab.kermit.io.RollingFileLogWriterConfig +import kotlinx.io.files.Path + +class SampleAndroid(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { + init { + Logger.addLogWriter( + RollingFileLogWriter( + config = RollingFileLogWriterConfig( + logFileName = logFileName, + logFilePath = Path(filePathString), + ) + ) + ) + } +} \ No newline at end of file diff --git a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt similarity index 91% rename from samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt rename to samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt index 297bfd7a..f864d853 100644 --- a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt +++ b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -15,7 +15,7 @@ import co.touchlab.kermit.io.RollingFileLogWriter import co.touchlab.kermit.io.RollingFileLogWriterConfig import kotlinx.io.files.Path -class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { +class SampleIOS(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { init { Logger.addLogWriter( RollingFileLogWriter( From 2afc15f97dec084ea560f558b96fff0319a0aa00 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Fri, 15 Nov 2024 17:04:57 -0500 Subject: [PATCH 11/15] renaming files --- .../touchlab/kermitsample/{SampleMobile.kt => SampleAndroid.kt} | 0 .../co/touchlab/kermitsample/{SampleMobile.kt => SampleIOS.kt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/{SampleMobile.kt => SampleAndroid.kt} (100%) rename samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/{SampleMobile.kt => SampleIOS.kt} (100%) diff --git a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleAndroid.kt similarity index 100% rename from samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt rename to samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleAndroid.kt diff --git a/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleIOS.kt similarity index 100% rename from samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt rename to samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleIOS.kt From 190132e1fe2c210b8cfd0ef926bb52758bb740ce Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Tue, 19 Nov 2024 12:56:57 -0500 Subject: [PATCH 12/15] merging in temporary changes --- .../co/touchlab/KermitSample/FirstFragment.kt | 4 +-- samples/sample/shared/build.gradle.kts | 22 +++++++++----- .../co/touchlab/kermitsample/SampleAndroid.kt | 29 ------------------- .../co/touchlab/kermitsample/SampleMobile.kt} | 2 +- 4 files changed, 18 insertions(+), 39 deletions(-) delete mode 100644 samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleAndroid.kt rename samples/sample/shared/src/{iosMain/kotlin/co/touchlab/kermitsample/SampleIOS.kt => mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt} (91%) diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 362a6cc8..116e8c6a 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -15,7 +15,7 @@ import android.view.View import androidx.fragment.app.Fragment import co.touchlab.KermitSample.databinding.FragmentFirstBinding import co.touchlab.kermit.Logger -import co.touchlab.kermitsample.SampleAndroid +import co.touchlab.kermitsample.SampleMobile /** * A simple [Fragment] subclass as the default destination in the navigation. @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleAndroid(context?.filesDir?.path ?: "") + val sample = SampleMobile(context?.filesDir?.path ?: "") val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 9d3c7673..12704873 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -8,6 +8,7 @@ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -59,13 +60,21 @@ kotlin { implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - androidMain.dependencies { - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + val mobileMain by creating { + dependsOn(commonMain.get()) + dependencies { + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + } } - iosMain.dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") + androidMain { + dependsOn(mobileMain) + } + iosMain { + dependsOn(commonMain.get()) + dependencies { + // Only if you want to talk to Kermit from Swift + implementation("co.touchlab:kermit-simple:${KERMIT_VERSION}") + } } } cocoapods { @@ -73,7 +82,6 @@ kotlin { homepage = "https://www.touchlab.co" framework { isStatic = true - // Only if you want to talk to Kermit from Swift export("co.touchlab:kermit-simple:${KERMIT_VERSION}") } diff --git a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleAndroid.kt b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleAndroid.kt deleted file mode 100644 index 5df98418..00000000 --- a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleAndroid.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2024 Touchlab - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ - -package co.touchlab.kermitsample - -import co.touchlab.kermit.Logger -import co.touchlab.kermit.io.RollingFileLogWriter -import co.touchlab.kermit.io.RollingFileLogWriterConfig -import kotlinx.io.files.Path - -class SampleAndroid(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { - init { - Logger.addLogWriter( - RollingFileLogWriter( - config = RollingFileLogWriterConfig( - logFileName = logFileName, - logFilePath = Path(filePathString), - ) - ) - ) - } -} \ No newline at end of file diff --git a/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleIOS.kt b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt similarity index 91% rename from samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleIOS.kt rename to samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt index f864d853..297bfd7a 100644 --- a/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleIOS.kt +++ b/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -15,7 +15,7 @@ import co.touchlab.kermit.io.RollingFileLogWriter import co.touchlab.kermit.io.RollingFileLogWriterConfig import kotlinx.io.files.Path -class SampleIOS(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { +class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { init { Logger.addLogWriter( RollingFileLogWriter( From 58e8514c0bd21f3a81bd3e6de4b2073da92248ed Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Tue, 19 Nov 2024 13:06:38 -0500 Subject: [PATCH 13/15] Update build.gradle.kts --- samples/sample/shared/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 12704873..b5e6c353 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -70,10 +70,10 @@ kotlin { dependsOn(mobileMain) } iosMain { - dependsOn(commonMain.get()) + dependsOn(mobileMain) dependencies { // Only if you want to talk to Kermit from Swift - implementation("co.touchlab:kermit-simple:${KERMIT_VERSION}") + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") } } } From 6e88f2878348170d0a92b68443ed7a86429d4011 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Tue, 19 Nov 2024 14:00:46 -0500 Subject: [PATCH 14/15] Update ContentView.swift --- .../sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift index 7ce2b0df..56cdb73e 100644 --- a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift +++ b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift @@ -15,14 +15,14 @@ import shared struct ContentView: View { - let common: SampleIOS + let common: SampleMobile init() { let filePath = NSHomeDirectory() + "/Documents/" let fileName = "KermitSampleLogs" ContentView.createLoggingFile(withName: fileName, atPath: filePath) - self.common = SampleIOS(filePathString: filePath, logFileName: fileName) + self.common = SampleMobile(filePathString: filePath, logFileName: fileName) } private static func createLoggingFile(withName name:String, atPath filePath: String){ From b1a7cbbac3fc4ef123d0ba0b97a5a3b767f9a087 Mon Sep 17 00:00:00 2001 From: Sam Hill Date: Tue, 19 Nov 2024 15:32:59 -0500 Subject: [PATCH 15/15] Re-order maven repos --- samples/sample-production/build.gradle.kts | 2 +- samples/sample/build.gradle.kts | 2 +- samples/sample/shared/build.gradle.kts | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/sample-production/build.gradle.kts b/samples/sample-production/build.gradle.kts index 23dac572..5f2b9444 100644 --- a/samples/sample-production/build.gradle.kts +++ b/samples/sample-production/build.gradle.kts @@ -23,10 +23,10 @@ plugins { allprojects { repositories { + mavenLocal() mavenCentral() maven(url = "https://oss.sonatype.org/content/repositories/snapshots") google() - mavenLocal() } } diff --git a/samples/sample/build.gradle.kts b/samples/sample/build.gradle.kts index 0c378781..a2c9aa89 100644 --- a/samples/sample/build.gradle.kts +++ b/samples/sample/build.gradle.kts @@ -24,10 +24,10 @@ version = "1.0-SNAPSHOT" allprojects { repositories { + mavenLocal() mavenCentral() maven(url = "https://oss.sonatype.org/content/repositories/snapshots") google() - mavenLocal() } } tasks.register("ciTest") { diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index b5e6c353..e738f83c 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -50,6 +50,8 @@ kotlin { nodejs() } + applyDefaultHierarchyTemplate() + sourceSets { commonMain.dependencies { implementation("co.touchlab:kermit:${KERMIT_VERSION}")