diff --git a/.github/PUBLISHING.md b/.github/PUBLISHING.md
index 00727128..3af4eb79 100644
--- a/.github/PUBLISHING.md
+++ b/.github/PUBLISHING.md
@@ -1,4 +1,4 @@
# Publishing
-Check [publishing](https://github.com/JavierSegoviaCordoba/gradle-plugins/blob/main/.github/PUBLISHING.md)
-from [JavierSC Gradle plugins](https://github.com/JavierSegoviaCordoba/gradle-plugins/)
+Check [publishing](https://github.com/JavierSegoviaCordoba/hubdle/blob/main/.github/PUBLISHING.md)
+from [JavierSC Hubdle](https://github.com/JavierSegoviaCordoba/hubdle/)
diff --git a/.github/renovate.json b/.github/renovate.json
index 916142a8..c6f8a6da 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -6,6 +6,9 @@
"commitBodyTable": true,
"gitIgnoredAuthors": [
"javiersegoviacordoba@gmail.com",
- "javier@segoviacordoba.com"
+ "javier@segoviacordoba.com",
+ "bot@renovateapp.com",
+ "29139614+renovate[bot]@users.noreply.github.com",
+ "action@github.com"
]
}
diff --git a/.github/workflows/build-changelog-renovate-bot.yaml b/.github/workflows/build-changelog-renovate-bot.yaml
index 5c23f723..33d1076d 100644
--- a/.github/workflows/build-changelog-renovate-bot.yaml
+++ b/.github/workflows/build-changelog-renovate-bot.yaml
@@ -7,6 +7,5 @@ on:
jobs:
add-updated-dependencies-to-changelog:
- uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/build-changelog-renovate-bot.yaml@main
- secrets:
- TOKEN_GITHUB_ACTION: '${{ secrets.TOKEN_GITHUB_ACTION }}'
+ uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/build-changelog-renovate-bot.yaml@hubdle
+ secrets: inherit
diff --git a/.github/workflows/build-kotlin-dispatcher.yaml b/.github/workflows/build-kotlin-dispatcher.yaml
index 6980b66a..728f1caf 100644
--- a/.github/workflows/build-kotlin-dispatcher.yaml
+++ b/.github/workflows/build-kotlin-dispatcher.yaml
@@ -15,13 +15,9 @@ on:
jobs:
build:
- uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/build-kotlin.yaml@main
+ uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/build-kotlin.yaml@hubdle
with:
gradle-args: '${{ github.event.inputs.gradle-args }}'
allow-github-actor-bots: false
publish-all-docs: '${{ github.event.inputs.publish-all-docs }}'
- secrets:
- OSS_USER: '${{ secrets.OSS_USER }}'
- OSS_TOKEN: '${{ secrets.OSS_TOKEN }}'
- OSS_STAGING_PROFILE_ID: '${{ secrets.OSS_STAGING_PROFILE_ID }}'
- SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
+ secrets: inherit
diff --git a/.github/workflows/build-kotlin.yaml b/.github/workflows/build-kotlin.yaml
index 0e420448..84575882 100644
--- a/.github/workflows/build-kotlin.yaml
+++ b/.github/workflows/build-kotlin.yaml
@@ -15,11 +15,7 @@ on:
jobs:
build:
- uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/build-kotlin.yaml@main
+ uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/build-kotlin.yaml@hubdle
with:
allow-github-actor-bots: false
- secrets:
- OSS_USER: '${{ secrets.OSS_USER }}'
- OSS_TOKEN: '${{ secrets.OSS_TOKEN }}'
- OSS_STAGING_PROFILE_ID: '${{ secrets.OSS_STAGING_PROFILE_ID }}'
- SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
+ secrets: inherit
diff --git a/.github/workflows/generate-version-tag.yaml b/.github/workflows/generate-version-tag.yaml
index d8763198..224f465d 100644
--- a/.github/workflows/generate-version-tag.yaml
+++ b/.github/workflows/generate-version-tag.yaml
@@ -28,9 +28,8 @@ on:
jobs:
generate:
- uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/generate-version-tag.yaml@main
+ uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/generate-version-tag.yaml@hubdle
with:
stage: '${{ github.event.inputs.stage }}'
scope: '${{ github.event.inputs.scope }}'
- secrets:
- TOKEN_GITHUB_ACTION: '${{ secrets.TOKEN_GITHUB_ACTION }}'
+ secrets: inherit
diff --git a/.github/workflows/publish-kotlin.yaml b/.github/workflows/publish-kotlin.yaml
index ec9b9bf9..2b89277b 100644
--- a/.github/workflows/publish-kotlin.yaml
+++ b/.github/workflows/publish-kotlin.yaml
@@ -7,15 +7,5 @@ on:
jobs:
publish:
- uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/publish-kotlin.yaml@main
- secrets:
- OSS_USER: '${{ secrets.OSS_USER }}'
- OSS_TOKEN: '${{ secrets.OSS_TOKEN }}'
- OSS_STAGING_PROFILE_ID: '${{ secrets.OSS_STAGING_PROFILE_ID }}'
- SIGNING_KEY_NAME: '${{ secrets.SIGNING_KEY_NAME }}'
- SIGNING_KEY_ID: '${{ secrets.SIGNING_KEY_ID }}'
- SIGNING_KEY_PASSPHRASE: '${{ secrets.SIGNING_KEY_PASSPHRASE }}'
- SIGNING_KEY: '${{ secrets.SIGNING_KEY }}'
- GRADLE_PUBLISH_KEY: '${{ secrets.GRADLE_PUBLISH_KEY }}'
- GRADLE_PUBLISH_SECRET: '${{ secrets.GRADLE_PUBLISH_SECRET }}'
- SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
+ uses: JavierSegoviaCordoba/reusable-workflows/.github/workflows/publish-kotlin.yaml@hubdle
+ secrets: inherit
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c22e009a..0f1f16b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@
### Changed
+- artifact to `com.javiersc.mokoki:mokoki`
+
### Deprecated
### Removed
@@ -14,12 +16,10 @@
### Updated
-- `org.jetbrains.kotlinx:binary-compatibility-validator -> 0.10.0`
-- `io.kotest:kotest-assertions-core -> 5.3.0`
+- `com.android.tools.build:gradle -> 7.2.1`
+- `org.jetbrains.kotlin:kotlin-serialization -> 1.7.10`
+- `org.jetbrains.kotlin:kotlin-gradle-plugin -> 1.7.10`
- `gradle -> 7.4.1`
-- `com.javiersc.gradle-plugins:all-plugins -> 0.1.0-rc.40`
-- `androidx.appcompat:appcompat -> 1.4.1`
-- `org.jetbrains.kotlinx:kotlinx-serialization-json -> 1.3.2`
## [0.1.0-alpha.9] - 2021-12-14
@@ -90,7 +90,7 @@
### Changed
-- Rename `mokoki` subproject to `mokoki-core`
+- Rename `mokoki` subproject to `mokoki`
## [0.1.0-alpha.1] - 2021-03-22
diff --git a/README.md b/README.md
index e7384e64..9309525e 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
-![Kotlin version](https://img.shields.io/badge/kotlin-1.6.10-blueviolet?logo=kotlin&logoColor=white)
-[![MavenCentral](https://img.shields.io/maven-central/v/com.javiersc.mokoki/mokoki-core?label=MavenCentral)](https://repo1.maven.org/maven2/com/javiersc/mokoki/mokoki-core/)
-[![Snapshot](https://img.shields.io/nexus/s/com.javiersc.mokoki/mokoki-core?server=https%3A%2F%2Foss.sonatype.org%2F&label=Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/com/javiersc/mokoki/mokoki-core/)
+![Kotlin version](https://img.shields.io/badge/kotlin-1.7.0-blueviolet?logo=kotlin&logoColor=white)
+[![MavenCentral](https://img.shields.io/maven-central/v/com.javiersc.mokoki/mokoki?label=MavenCentral)](https://repo1.maven.org/maven2/com/javiersc/mokoki/mokoki/)
+[![Snapshot](https://img.shields.io/nexus/s/com.javiersc.mokoki/mokoki?server=https%3A%2F%2Foss.sonatype.org%2F&label=Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/com/javiersc/mokoki/mokoki/)
[![Build](https://img.shields.io/github/workflow/status/JavierSegoviaCordoba/mokoki/build-kotlin?label=Build&logo=GitHub)](https://github.com/JavierSegoviaCordoba/mokoki/tree/main)
-[![Quality](https://img.shields.io/sonar/quality_gate/JavierSegoviaCordoba_mokoki?label=Quality&logo=SonarCloud&logoColor=white&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=JavierSegoviaCordoba_mokoki)
-[![Tech debt](https://img.shields.io/sonar/tech_debt/JavierSegoviaCordoba_mokoki?label=Tech%20debt&logo=SonarCloud&logoColor=white&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=JavierSegoviaCordoba_mokoki)
+[![Coverage](https://img.shields.io/sonar/coverage/com.javiersc.mokoki:mokoki?label=Coverage&logo=SonarCloud&logoColor=white&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=com.javiersc.mokoki:mokoki)
+[![Quality](https://img.shields.io/sonar/quality_gate/com.javiersc.mokoki:mokoki?label=Quality&logo=SonarCloud&logoColor=white&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=com.javiersc.mokoki:mokoki)
+[![Tech debt](https://img.shields.io/sonar/tech_debt/com.javiersc.mokoki:mokoki?label=Tech%20debt&logo=SonarCloud&logoColor=white&server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=com.javiersc.mokoki:mokoki)
# [Mokoki](https://mokoki.javiersc.com)
@@ -24,7 +25,7 @@ available at Maven Central.
- Logger:
```kotlin
-implementation("com.javiersc.mokoki:mokoki-core:$version")
+implementation("com.javiersc.mokoki:mokoki:$version")
```
- Serialization
diff --git a/build.gradle.kts b/build.gradle.kts
index 0e094e88..494dc431 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,7 +13,7 @@ hubdle {
config {
analysis()
binaryCompatibilityValidator()
- // coverage()
+ coverage()
documentation {
changelog()
readme {
diff --git a/gradle.properties b/gradle.properties
index a9088321..741d7c12 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,8 +1,8 @@
####################################################################################################
### CONFIGURATION ###
####################################################################################################
-root.project.name=mokoki
-main.project.name=mokoki-core
+root.project.name=mokoki-project
+main.project.name=mokoki
project.group=com.javiersc.mokoki
####################################################################################################
### CODE ANALYSIS ###
@@ -29,16 +29,13 @@ pom.scm.developerConnection=scm:git:git@github.com:JavierSegoviaCordoba/mokoki.g
####################################################################################################
android.useAndroidX=true
kotlin.code.style=official
+kotlin.incremental.useClasspathSnapshot=true
kotlin.js.compiler=both
-kotlin.mpp.enableGranularSourceSetsMetadata=true
-kotlin.native.enableDependencyPropagation=false
org.gradle.caching=true
#org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true
-org.gradle.vfs.watch=true
#org.gradle.unsafe.configuration-cache=true
#org.gradle.unsafe.configuration-cache-problems=warn
#org.gradle.unsafe.configuration-cache.max-problems=100
signing.gnupg.executable=gpg
-android.disableAutomaticComponentCreation=true
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 60d897bc..02ed7d31 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,7 +1,7 @@
[versions]
-android = "7.2.0"
-hubdle = "0.2.0-alpha.21"
-kotlin = "1.6.10"
+android = "7.2.1"
+hubdle = "0.2.0-alpha.27"
+kotlin = "1.7.10"
[libraries]
android-toolsBuild-gradle = { module = "com.android.tools.build:gradle", version.ref = "android" }
diff --git a/mokoki-core/androidMain/AndroidManifest.xml b/mokoki-core/androidMain/AndroidManifest.xml
deleted file mode 100644
index 2475e61c..00000000
--- a/mokoki-core/androidMain/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/IOSMokokiLogger.kt b/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/IOSMokokiLogger.kt
deleted file mode 100644
index 222dc52b..00000000
--- a/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/IOSMokokiLogger.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.javiersc.mokoki
-
-import com.javiersc.mokoki.internal.buildMokokiMessage
-import kotlin.reflect.KClass
-import kotlin.reflect.KType
-import platform.Foundation.NSLog
-import platform.Foundation.NSString
-
-public open class IOSMokokiLogger(
- private val minPriority: Priority = Priority.DEBUG,
-) : MokokiLogger {
-
- override var useCompatibleMode: Boolean = false
-
- public var defaultTag: String = ""
-
- override fun isLoggable(priority: Priority): Boolean = priority.isLoggable(minPriority)
-
- override fun log(
- priority: Priority,
- tag: String?,
- kClass: KClass,
- kType: KType,
- message: T,
- ) {
- val lines: List = buildMokokiMessage(priority, tag, message)
-
- for (line in lines) {
- NSLog(message as NSString)
- }
- }
-}
diff --git a/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt b/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt
deleted file mode 100644
index 94da1a21..00000000
--- a/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.javiersc.mokoki.internal
-
-import platform.Foundation.NSThread
-
-internal actual val fileName
- get() = "file ${stackTrace?.fileName ?: "Unknown"}"
-
-internal actual val className
- get() = "class ${
- stackTrace?.className?.split(".")?.lastOrNull() ?: "Unknown"
- }"
-
-internal actual val methodName
- get() = "fun ${stackTrace?.methodName ?: "Unknown"}"
-
-internal actual val lineNumber
- get() = "line Unknown"
-
-internal actual val fileLink
- get() = "(${stackTrace?.fileName}:${stackTrace?.lineNumber})"
-
-private data class StackTraceElement(
- val fileName: String,
- val className: String?,
- val methodName: String?,
- val lineNumber: String?,
-)
-
-@Suppress("TooGenericExceptionCaught")
-private val stackTrace: StackTraceElement?
- get() =
- try {
- val lines: List = NSThread.callStackSymbols.map { it?.toString() }
- val index = 6
- val fileName =
- if (
- lines[index]
- ?.replaceAfter("#", "")
- ?.replace("#", "")
- ?.replaceBeforeLast(".", "")
- ?.replace(".", "")
- ?.first()
- ?.isUpperCase() == true
- ) {
- lines[index]
- ?.replaceAfter("#", "")
- ?.replace("#", "")
- ?.replaceBeforeLast(".", "")
- ?.replace(".", "")
- } else {
- lines[index + 1]
- ?.replaceBefore("$", "")
- ?.replaceFirst("$", "")
- ?.replaceAfter("$", "")
- ?.replace("$", "")
- }
-
- val methodName =
- lines[index]
- ?.replaceBefore("#", "")
- ?.replace("#", "")
- ?.replaceAfter("(", "")
- ?.replace("(", "")
-
- StackTraceElement(
- fileName = fileName?.let { "$it.kt" } ?: "Unknown",
- className = fileName ?: "Unknown",
- methodName = methodName,
- lineNumber = "1"
- )
- } catch (throwable: Throwable) {
- println("Mokoki has not been able to get the StackTrace")
- null
- }
diff --git a/mokoki-serialization/androidMain/AndroidManifest.xml b/mokoki-serialization/androidMain/AndroidManifest.xml
deleted file mode 100644
index a84fc647..00000000
--- a/mokoki-serialization/androidMain/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/mokoki-serialization/api/android/mokoki-serialization.api b/mokoki-serialization/api/android/mokoki-serialization.api
index 6847039f..6f6c4c61 100644
--- a/mokoki-serialization/api/android/mokoki-serialization.api
+++ b/mokoki-serialization/api/android/mokoki-serialization.api
@@ -1,10 +1,3 @@
-public final class com/javiersc/mokoki/serialization/BuildConfig {
- public static final field BUILD_TYPE Ljava/lang/String;
- public static final field DEBUG Z
- public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
- public fun ()V
-}
-
public class com/javiersc/mokoki/serialization/PrintSerializableMokokiLogger : com/javiersc/mokoki/MokokiLogger {
public fun ()V
public fun (Lcom/javiersc/mokoki/Priority;)V
diff --git a/mokoki-serialization/build.gradle.kts b/mokoki-serialization/build.gradle.kts
index 349ff112..52bd749c 100644
--- a/mokoki-serialization/build.gradle.kts
+++ b/mokoki-serialization/build.gradle.kts
@@ -6,7 +6,7 @@ hubdle {
config {
explicitApi()
languageSettings {
- optIn("kotlinx.serialization.ExperimentalSerializationApi")
+ experimentalSerializationApi()
}
publishing()
}
@@ -19,7 +19,7 @@ hubdle {
common {
main {
dependencies {
- api(projects.mokokiCore)
+ api(projects.mokoki)
}
}
test {
@@ -30,11 +30,17 @@ hubdle {
}
android()
- ios()
- iosArm64()
- iosSimulatorArm64()
- iosX64()
+
+ darwin {
+ enableAll()
+ }
+
jvm()
+ jvmAndAndroid()
+
+ mingw {
+ enableAll()
+ }
}
}
}
diff --git a/mokoki-serialization/commonMain/kotlin/com/javiersc/mokoki/serialization/PrintSerializableMokokiLogger.kt b/mokoki-serialization/common/main/kotlin/com/javiersc/mokoki/serialization/PrintSerializableMokokiLogger.kt
similarity index 100%
rename from mokoki-serialization/commonMain/kotlin/com/javiersc/mokoki/serialization/PrintSerializableMokokiLogger.kt
rename to mokoki-serialization/common/main/kotlin/com/javiersc/mokoki/serialization/PrintSerializableMokokiLogger.kt
diff --git a/mokoki-serialization/commonMain/kotlin/com/javiersc/mokoki/serialization/internal/BuildMokokiSerialization.kt b/mokoki-serialization/common/main/kotlin/com/javiersc/mokoki/serialization/internal/BuildMokokiSerialization.kt
similarity index 100%
rename from mokoki-serialization/commonMain/kotlin/com/javiersc/mokoki/serialization/internal/BuildMokokiSerialization.kt
rename to mokoki-serialization/common/main/kotlin/com/javiersc/mokoki/serialization/internal/BuildMokokiSerialization.kt
diff --git a/mokoki-serialization/commonTest/kotlin/com/javiersc/mokoki/MokokiSerializationTest.kt b/mokoki-serialization/common/test/kotlin/com/javiersc/mokoki/MokokiSerializationTest.kt
similarity index 98%
rename from mokoki-serialization/commonTest/kotlin/com/javiersc/mokoki/MokokiSerializationTest.kt
rename to mokoki-serialization/common/test/kotlin/com/javiersc/mokoki/MokokiSerializationTest.kt
index befff91d..ef588f42 100644
--- a/mokoki-serialization/commonTest/kotlin/com/javiersc/mokoki/MokokiSerializationTest.kt
+++ b/mokoki-serialization/common/test/kotlin/com/javiersc/mokoki/MokokiSerializationTest.kt
@@ -2,12 +2,14 @@
package com.javiersc.mokoki
+import com.javiersc.kotlin.test.IgnoreMINGW
import com.javiersc.mokoki.test.internal.lineNumberForTest
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlinx.serialization.Serializable
+@IgnoreMINGW
internal class MokokiSerializationTest {
private val testLogger = TestMokokiSerializationLogger(minPriority = Priority.VERBOSE)
@@ -24,8 +26,8 @@ internal class MokokiSerializationTest {
@Test
fun json_log_V() {
- val n = lineNumberForTest
logV("Some tag") { userString }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -47,8 +49,8 @@ internal class MokokiSerializationTest {
@Test
fun json_log_D() {
- val n = lineNumberForTest
logD("Some tag") { userString }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -70,8 +72,8 @@ internal class MokokiSerializationTest {
@Test
fun json_log_I() {
- val n = lineNumberForTest
logI("Some tag") { userString }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -93,8 +95,8 @@ internal class MokokiSerializationTest {
@Test
fun json_log_W() {
- val n = lineNumberForTest
logW("Some tag") { userString }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -116,8 +118,8 @@ internal class MokokiSerializationTest {
@Test
fun json_log_E() {
- val nu = lineNumberForTest
logE("Some tag") { userString }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -139,8 +141,8 @@ internal class MokokiSerializationTest {
@Test
fun json_log_WTF() {
- val nu = lineNumberForTest
logWTF("Some tag") { userString }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -162,8 +164,8 @@ internal class MokokiSerializationTest {
@Test
fun serializable_log_V() {
- val nu = lineNumberForTest
logV("Some tag") { user }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -185,8 +187,8 @@ internal class MokokiSerializationTest {
@Test
fun serializable_log_D() {
- val nu = lineNumberForTest
logD("Some tag") { user }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -208,8 +210,8 @@ internal class MokokiSerializationTest {
@Test
fun serializable_log_I() {
- val nu = lineNumberForTest
logI("Some tag") { user }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -231,8 +233,8 @@ internal class MokokiSerializationTest {
@Test
fun serializable_log_W() {
- val nu = lineNumberForTest
logW("Some tag") { user }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -254,8 +256,8 @@ internal class MokokiSerializationTest {
@Test
fun serializable_log_E() {
- val nu = lineNumberForTest
logE("Some tag") { user }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -277,8 +279,8 @@ internal class MokokiSerializationTest {
@Test
fun serializable_log_WTF() {
- val nu = lineNumberForTest
logWTF("Some tag") { user }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
diff --git a/mokoki-serialization/commonTest/kotlin/com/javiersc/mokoki/TestMokokiSerializationLogger.kt b/mokoki-serialization/common/test/kotlin/com/javiersc/mokoki/TestMokokiSerializationLogger.kt
similarity index 100%
rename from mokoki-serialization/commonTest/kotlin/com/javiersc/mokoki/TestMokokiSerializationLogger.kt
rename to mokoki-serialization/common/test/kotlin/com/javiersc/mokoki/TestMokokiSerializationLogger.kt
diff --git a/mokoki-test/androidMain/AndroidManifest.xml b/mokoki-test/androidMain/AndroidManifest.xml
deleted file mode 100644
index 5945e835..00000000
--- a/mokoki-test/androidMain/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/mokoki-test/api/android/mokoki-test.api b/mokoki-test/api/android/mokoki-test.api
index ba65e4af..c4c41ba3 100644
--- a/mokoki-test/api/android/mokoki-test.api
+++ b/mokoki-test/api/android/mokoki-test.api
@@ -1,11 +1,4 @@
-public final class com/javiersc/mokoki/test/BuildConfig {
- public static final field BUILD_TYPE Ljava/lang/String;
- public static final field DEBUG Z
- public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
- public fun ()V
-}
-
public final class com/javiersc/mokoki/test/internal/LoggerNames_jvmAndAndroidKt {
- public static final fun getLineNumberForTest ()I
+ public static final fun getLineNumberForTest (Ljava/lang/String;)I
}
diff --git a/mokoki-test/api/jvm/mokoki-test.api b/mokoki-test/api/jvm/mokoki-test.api
index 00806f1c..c4c41ba3 100644
--- a/mokoki-test/api/jvm/mokoki-test.api
+++ b/mokoki-test/api/jvm/mokoki-test.api
@@ -1,4 +1,4 @@
public final class com/javiersc/mokoki/test/internal/LoggerNames_jvmAndAndroidKt {
- public static final fun getLineNumberForTest ()I
+ public static final fun getLineNumberForTest (Ljava/lang/String;)I
}
diff --git a/mokoki-test/build.gradle.kts b/mokoki-test/build.gradle.kts
index b3138c35..40dee38c 100644
--- a/mokoki-test/build.gradle.kts
+++ b/mokoki-test/build.gradle.kts
@@ -9,13 +9,20 @@ hubdle {
}
kotlin {
multiplatform {
+ common()
+
android()
- ios()
- iosArm64()
- iosSimulatorArm64()
- iosX64()
+
+ darwin {
+ enableAll()
+ }
+
jvm()
jvmAndAndroid()
+
+ mingw {
+ enableAll()
+ }
}
}
}
diff --git a/mokoki-test/common/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.kt b/mokoki-test/common/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.kt
new file mode 100644
index 00000000..bf630c30
--- /dev/null
+++ b/mokoki-test/common/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.kt
@@ -0,0 +1,3 @@
+package com.javiersc.mokoki.test.internal
+
+public expect val String?.lineNumberForTest: Int
diff --git a/mokoki-test/commonMain/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.kt b/mokoki-test/commonMain/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.kt
deleted file mode 100644
index 61a379fc..00000000
--- a/mokoki-test/commonMain/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package com.javiersc.mokoki.test.internal
-
-public expect val lineNumberForTest: Int
diff --git a/mokoki-test/darwin/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.darwin.kt b/mokoki-test/darwin/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.darwin.kt
new file mode 100644
index 00000000..d1b1ec30
--- /dev/null
+++ b/mokoki-test/darwin/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.darwin.kt
@@ -0,0 +1,4 @@
+package com.javiersc.mokoki.test.internal
+
+public actual val String?.lineNumberForTest: Int
+ get() = this?.substringAfter(".kt:")?.substringBefore(")")?.toIntOrNull() ?: 1
diff --git a/mokoki-test/jvmAndAndroidMain/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.jvmAndAndroid.kt b/mokoki-test/jvmAndAndroid/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.jvmAndAndroid.kt
similarity index 83%
rename from mokoki-test/jvmAndAndroidMain/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.jvmAndAndroid.kt
rename to mokoki-test/jvmAndAndroid/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.jvmAndAndroid.kt
index fb0a7ca9..c9ad97a5 100644
--- a/mokoki-test/jvmAndAndroidMain/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.jvmAndAndroid.kt
+++ b/mokoki-test/jvmAndAndroid/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.jvmAndAndroid.kt
@@ -1,7 +1,7 @@
package com.javiersc.mokoki.test.internal
-public actual val lineNumberForTest: Int
- get() = (stackTraceForTests?.lineNumber ?: -2) + 1
+public actual val String?.lineNumberForTest: Int
+ get() = (stackTraceForTests?.lineNumber ?: +2) - 1
private val stackTraceForTests: StackTraceElement?
get() =
diff --git a/mokoki-test/mingw/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.mingw.kt b/mokoki-test/mingw/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.mingw.kt
new file mode 100644
index 00000000..d1b1ec30
--- /dev/null
+++ b/mokoki-test/mingw/main/kotlin/com/javiersc/mokoki/test/internal/LoggerNames.mingw.kt
@@ -0,0 +1,4 @@
+package com.javiersc.mokoki.test.internal
+
+public actual val String?.lineNumberForTest: Int
+ get() = this?.substringAfter(".kt:")?.substringBefore(")")?.toIntOrNull() ?: 1
diff --git a/mokoki-core/MODULE.md b/mokoki/MODULE.md
similarity index 58%
rename from mokoki-core/MODULE.md
rename to mokoki/MODULE.md
index 02d0b9fc..001ba55b 100644
--- a/mokoki-core/MODULE.md
+++ b/mokoki/MODULE.md
@@ -1,9 +1,9 @@
-# Module mokoki-core
+# Module mokoki
Core module which contains the abstractions and pure Kotlin logic.
### Download from MavenCentral
```kotlin
-implementation("com.javiersc.mokoki:mokoki-core:$version")
+implementation("com.javiersc.mokoki:mokoki:$version")
```
diff --git a/mokoki-core/androidMain/kotlin/com/javiersc/mokoki/AndroidMokokiLogger.kt b/mokoki/android/main/kotlin/com/javiersc/mokoki/AndroidMokokiLogger.kt
similarity index 100%
rename from mokoki-core/androidMain/kotlin/com/javiersc/mokoki/AndroidMokokiLogger.kt
rename to mokoki/android/main/kotlin/com/javiersc/mokoki/AndroidMokokiLogger.kt
diff --git a/mokoki-core/androidMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.android.kt b/mokoki/android/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.android.kt
similarity index 100%
rename from mokoki-core/androidMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.android.kt
rename to mokoki/android/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.android.kt
diff --git a/mokoki-core/api/android/mokoki-core.api b/mokoki/api/android/mokoki.api
similarity index 91%
rename from mokoki-core/api/android/mokoki-core.api
rename to mokoki/api/android/mokoki.api
index e479a4a3..31ee5681 100644
--- a/mokoki-core/api/android/mokoki-core.api
+++ b/mokoki/api/android/mokoki.api
@@ -10,13 +10,6 @@ public class com/javiersc/mokoki/AndroidMokokiLogger : com/javiersc/mokoki/Mokok
public fun setUseCompatibleMode (Z)V
}
-public final class com/javiersc/mokoki/BuildConfig {
- public static final field BUILD_TYPE Ljava/lang/String;
- public static final field DEBUG Z
- public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
- public fun ()V
-}
-
public final class com/javiersc/mokoki/LoggerSeparatorKt {
public static final fun LoggerSeparator (Z)Ljava/lang/String;
public static synthetic fun LoggerSeparator$default (ZILjava/lang/Object;)Ljava/lang/String;
@@ -31,7 +24,7 @@ public abstract interface class com/javiersc/mokoki/MokokiLogger {
}
public final class com/javiersc/mokoki/MokokiLogger$Companion {
- public final fun getInternalloggers ()Ljava/util/List;
+ public final fun getInternalLoggers ()Ljava/util/List;
public final fun getLoggers ()Ljava/util/List;
public final fun install ([Lcom/javiersc/mokoki/MokokiLogger;)V
public final fun uninstallAllLoggers ()V
diff --git a/mokoki-core/api/jvm/mokoki-core.api b/mokoki/api/jvm/mokoki.api
similarity index 97%
rename from mokoki-core/api/jvm/mokoki-core.api
rename to mokoki/api/jvm/mokoki.api
index 53c37025..1617d181 100644
--- a/mokoki-core/api/jvm/mokoki-core.api
+++ b/mokoki/api/jvm/mokoki.api
@@ -12,7 +12,7 @@ public abstract interface class com/javiersc/mokoki/MokokiLogger {
}
public final class com/javiersc/mokoki/MokokiLogger$Companion {
- public final fun getInternalloggers ()Ljava/util/List;
+ public final fun getInternalLoggers ()Ljava/util/List;
public final fun getLoggers ()Ljava/util/List;
public final fun install ([Lcom/javiersc/mokoki/MokokiLogger;)V
public final fun uninstallAllLoggers ()V
diff --git a/mokoki-core/build.gradle.kts b/mokoki/build.gradle.kts
similarity index 69%
rename from mokoki-core/build.gradle.kts
rename to mokoki/build.gradle.kts
index 6c69b476..1caabf49 100644
--- a/mokoki-core/build.gradle.kts
+++ b/mokoki/build.gradle.kts
@@ -12,18 +12,24 @@ hubdle {
common {
test {
dependencies {
+ implementation(javierscKotlinStdlib())
implementation(projects.mokokiTest)
}
}
}
android()
- ios()
- iosArm64()
- iosSimulatorArm64()
- iosX64()
+
+ darwin {
+ enableAll()
+ }
+
jvm()
jvmAndAndroid()
+
+ mingw {
+ enableAll()
+ }
}
}
}
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.kt
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/LoggerSeparator.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/LoggerSeparator.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/LoggerSeparator.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/LoggerSeparator.kt
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/Mokoki.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/Mokoki.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/Mokoki.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/Mokoki.kt
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/MokokiLogger.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/MokokiLogger.kt
similarity index 67%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/MokokiLogger.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/MokokiLogger.kt
index b9476b94..e89904c7 100644
--- a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/MokokiLogger.kt
+++ b/mokoki/common/main/kotlin/com/javiersc/mokoki/MokokiLogger.kt
@@ -1,5 +1,6 @@
package com.javiersc.mokoki
+import kotlin.native.concurrent.ThreadLocal
import kotlin.reflect.KClass
import kotlin.reflect.KType
@@ -17,21 +18,20 @@ public interface MokokiLogger {
message: T,
)
+ @ThreadLocal
public companion object {
- @PublishedApi
- @Suppress("ObjectPropertyName")
- internal val internalloggers: MutableList = mutableListOf()
+ @PublishedApi internal val internalLoggers: MutableList = mutableListOf()
public val loggers: List
- get() = internalloggers
+ get() = internalLoggers
public fun install(vararg loggers: MokokiLogger) {
- this.internalloggers.addAll(loggers)
+ this.internalLoggers.addAll(loggers)
}
public fun uninstallAllLoggers() {
- internalloggers.clear()
+ internalLoggers.clear()
}
}
}
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/PrintMokokiLogger.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/PrintMokokiLogger.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/PrintMokokiLogger.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/PrintMokokiLogger.kt
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/Priority.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/Priority.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/Priority.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/Priority.kt
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/internal/BuildMokokiMessage.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/internal/BuildMokokiMessage.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/internal/BuildMokokiMessage.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/internal/BuildMokokiMessage.kt
diff --git a/mokoki-core/commonMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt b/mokoki/common/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt
similarity index 100%
rename from mokoki-core/commonMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt
rename to mokoki/common/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.kt
diff --git a/mokoki-core/commonTest/kotlin/com/javiersc/mokoki/MokokiTest.kt b/mokoki/common/test/kotlin/com/javiersc/mokoki/MokokiTest.kt
similarity index 55%
rename from mokoki-core/commonTest/kotlin/com/javiersc/mokoki/MokokiTest.kt
rename to mokoki/common/test/kotlin/com/javiersc/mokoki/MokokiTest.kt
index b45710a5..a7e6ca11 100644
--- a/mokoki-core/commonTest/kotlin/com/javiersc/mokoki/MokokiTest.kt
+++ b/mokoki/common/test/kotlin/com/javiersc/mokoki/MokokiTest.kt
@@ -2,11 +2,14 @@
package com.javiersc.mokoki
+import com.javiersc.kotlin.test.IgnoreDARWIN
+import com.javiersc.kotlin.test.IgnoreMINGW
import com.javiersc.mokoki.test.internal.lineNumberForTest
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
+@IgnoreMINGW
internal class MokokiTest {
private val testLogger = TestMokokiLogger(minPriority = Priority.VERBOSE)
@@ -23,8 +26,8 @@ internal class MokokiTest {
@Test
fun log_V() {
- val n = lineNumberForTest
logV("Some tag") { "Some message" }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -33,14 +36,14 @@ internal class MokokiTest {
├─────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Some message │
└─────────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
@Test
fun log_D() {
- val n = lineNumberForTest
logD("Some tag") { "Some message" }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -49,14 +52,14 @@ internal class MokokiTest {
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Some message │
└───────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
@Test
fun log_I() {
- val n = lineNumberForTest
logI("Some tag") { "Some message" }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -65,14 +68,14 @@ internal class MokokiTest {
├──────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Some message │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
@Test
fun log_W() {
- val n = lineNumberForTest
logW("Some tag") { "Some message" }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -81,14 +84,14 @@ internal class MokokiTest {
├──────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Some message │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
@Test
fun log_E() {
- val n = lineNumberForTest
logE("Some tag") { "Some message" }
+ val n = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -97,13 +100,14 @@ internal class MokokiTest {
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Some message │
└───────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
+
@Test
fun log_WTF() {
- val nu = lineNumberForTest
logWTF("Some tag") { "Some message" }
+ val nu = testLogger.lastMessage.lineNumberForTest
testLogger.assert(
"""
@@ -112,66 +116,23 @@ internal class MokokiTest {
├────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Some message │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
+ @IgnoreDARWIN
@Test
fun log_some_throwable() {
- val nu = lineNumberForTest
logE("Some tag") { IllegalStateException("Some message") }
+ val nu = testLogger.lastMessage.lineNumberForTest
- testLogger.assert(
+ testLogger.assertContains(
"""
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Some tag │ ERROR.(MokokiTest.kt:$nu) │ file MokokiTest.kt │ class MokokiTest │ fun log_some_throwable │ line $nu │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ java.lang.IllegalStateException: Some message │
- │ at com.javiersc.mokoki.MokokiTest.log_some_throwable(MokokiTest.kt:$nu) │
- │ at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) │
- │ at java.base/java.lang.reflect.Method.invoke(Method.java:577) │
- │ at org.junit.runners.model.FrameworkMethod${'$'}1.runReflectiveCall(FrameworkMethod.java:59) │
- │ at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) │
- │ at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) │
- │ at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) │
- │ at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) │
- │ at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) │
- │ at org.junit.runners.ParentRunner${'$'}3.evaluate(ParentRunner.java:306) │
- │ at org.junit.runners.BlockJUnit4ClassRunner${'$'}1.evaluate(BlockJUnit4ClassRunner.java:100) │
- │ at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) │
- │ at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) │
- │ at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) │
- │ at org.junit.runners.ParentRunner${'$'}4.run(ParentRunner.java:331) │
- │ at org.junit.runners.ParentRunner${'$'}1.schedule(ParentRunner.java:79) │
- │ at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) │
- │ at org.junit.runners.ParentRunner.access${'$'}100(ParentRunner.java:66) │
- │ at org.junit.runners.ParentRunner${'$'}2.evaluate(ParentRunner.java:293) │
- │ at org.junit.runners.ParentRunner${'$'}3.evaluate(ParentRunner.java:306) │
- │ at org.junit.runners.ParentRunner.run(ParentRunner.java:413) │
- │ at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) │
- │ at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) │
- │ at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) │
- │ at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) │
- │ at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) │
- │ at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) │
- │ at java.base/java.lang.reflect.Method.invoke(Method.java:577) │
- │ at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) │
- │ at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) │
- │ at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) │
- │ at org.gradle.internal.dispatch.ProxyDispatchAdapter${'$'}DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) │
- │ at jdk.proxy1/jdk.proxy1.${'$'}Proxy2.processTestClass(Unknown Source) │
- │ at org.gradle.api.internal.tasks.testing.worker.TestWorker${'$'}2.run(TestWorker.java:176) │
- │ at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) │
- │ at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) │
- │ at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) │
- │ at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) │
- │ at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) │
- │ at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) │
- │ at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) │
- │ at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) │
- │ │
- └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
- """.trimIndent()
+ """.trimIndent(),
)
}
}
diff --git a/mokoki-core/commonTest/kotlin/com/javiersc/mokoki/TestMokokiLogger.kt b/mokoki/common/test/kotlin/com/javiersc/mokoki/TestMokokiLogger.kt
similarity index 64%
rename from mokoki-core/commonTest/kotlin/com/javiersc/mokoki/TestMokokiLogger.kt
rename to mokoki/common/test/kotlin/com/javiersc/mokoki/TestMokokiLogger.kt
index 39f64c33..10a6e154 100644
--- a/mokoki-core/commonTest/kotlin/com/javiersc/mokoki/TestMokokiLogger.kt
+++ b/mokoki/common/test/kotlin/com/javiersc/mokoki/TestMokokiLogger.kt
@@ -3,10 +3,11 @@ package com.javiersc.mokoki
import com.javiersc.kotlin.stdlib.ansiColor
import com.javiersc.mokoki.internal.buildMokokiMessage
import io.kotest.matchers.shouldBe
+import io.kotest.matchers.string.shouldContain
import kotlin.reflect.KClass
import kotlin.reflect.KType
-internal class TestMokokiLogger(minPriority: Priority) : PrintMokokiLogger(minPriority) {
+class TestMokokiLogger(minPriority: Priority) : PrintMokokiLogger(minPriority) {
var lastMessage: String? = null
private set
@@ -27,7 +28,7 @@ internal class TestMokokiLogger(minPriority: Priority) : PrintMokokiLogger(minPr
}
}
-internal fun TestMokokiLogger.assert(message: String) {
+fun TestMokokiLogger.assert(message: String) {
val expect =
"\n" +
(message
@@ -49,6 +50,28 @@ internal fun TestMokokiLogger.assert(message: String) {
actual.shouldBe(expect)
}
+fun TestMokokiLogger.assertContains(message: String) {
+ val expect =
+ "\n" +
+ (message
+ .lines()
+ .filter(String::isNotBlank)
+ .map { it.dropWhile { char -> char.shouldDrop } }
+ .map { it.dropLastWhile { char -> char.shouldDropLast } }
+ .joinToString("\n"))
+
+ val actual =
+ "\n" +
+ (lastMessage!!
+ .lines()
+ .filter(String::isNotBlank)
+ .map { it.dropWhile { char -> char.shouldDrop } }
+ .map { it.dropLastWhile { char -> char.shouldDropLast } }
+ .joinToString("\n"))
+
+ actual.shouldContain(expect)
+}
+
private val Char.shouldDrop: Boolean
get() = this != '┌' && this != '│' && this != '├' && this != '└'
diff --git a/mokoki-core/iosMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.ios.kt b/mokoki/darwin/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.darwin.kt
similarity index 100%
rename from mokoki-core/iosMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.ios.kt
rename to mokoki/darwin/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.darwin.kt
diff --git a/mokoki/darwin/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.darwin.kt b/mokoki/darwin/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.darwin.kt
new file mode 100644
index 00000000..8a10f6cb
--- /dev/null
+++ b/mokoki/darwin/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.darwin.kt
@@ -0,0 +1,49 @@
+package com.javiersc.mokoki.internal
+
+internal actual val fileName
+ get() = "file ${stackTrace?.fileName ?: "Unknown"}"
+
+internal actual val className
+ get() = "class ${
+ stackTrace?.className?.split(".")?.lastOrNull() ?: "Unknown"
+ }"
+
+internal actual val methodName
+ get() = "fun ${stackTrace?.methodName ?: "Unknown"}"
+
+internal actual val lineNumber
+ get() = "line ${stackTrace?.lineNumber ?: "Unknown"}"
+
+internal actual val fileLink
+ get() = "(${stackTrace?.fileName}:${stackTrace?.lineNumber})"
+
+private data class StackTraceElement(
+ val fileName: String,
+ val className: String?,
+ val methodName: String?,
+ val lineNumber: String?,
+)
+
+private val stackTrace: StackTraceElement?
+ get() =
+ try {
+ throw IllegalStateException("MOKOKI INTERNAL ERROR")
+ } catch (exception: IllegalStateException) {
+ val lines = exception.getStackTrace().toList()
+ val line =
+ lines
+ .dropWhile { !it.contains("log(com.javiersc.mokoki.Priority") }
+ .dropWhile { it.contains("log(com.javiersc.mokoki.Priority") }
+ .firstOrNull()
+
+ val fileName = line?.substringAfterLast("/")?.substringBefore(":")
+ val className = line?.substringAfter("\$")?.substringBefore("\$")
+ val methodName = line?.substringBefore("\$FUNCTION_REFERENCE")?.substringAfterLast("\$")
+ val lineNumber = line?.substringAfterLast(".kt:")?.substringBefore(":")
+
+ if (fileName != null && className != null && methodName != null && lineNumber != null) {
+ StackTraceElement(fileName, className, methodName, lineNumber)
+ } else {
+ null
+ }
+ }
diff --git a/mokoki-core/jvmMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.jvm.kt b/mokoki/jvm/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.jvm.kt
similarity index 100%
rename from mokoki-core/jvmMain/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.jvm.kt
rename to mokoki/jvm/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.jvm.kt
diff --git a/mokoki-core/jvmAndAndroidMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.jvmAndAndroid.kt b/mokoki/jvmAndAndroid/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.jvmAndAndroid.kt
similarity index 100%
rename from mokoki-core/jvmAndAndroidMain/kotlin/com/javiersc/mokoki/internal/LoggerNames.jvmAndAndroid.kt
rename to mokoki/jvmAndAndroid/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.jvmAndAndroid.kt
diff --git a/mokoki/mingw/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.mingw.kt b/mokoki/mingw/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.mingw.kt
new file mode 100644
index 00000000..d0e5f216
--- /dev/null
+++ b/mokoki/mingw/main/kotlin/com/javiersc/mokoki/DefaultMokokiLogger.mingw.kt
@@ -0,0 +1,3 @@
+package com.javiersc.mokoki
+
+public actual typealias DefaultMokokiLogger = PrintMokokiLogger
diff --git a/mokoki/mingw/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.mingw.kt b/mokoki/mingw/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.mingw.kt
new file mode 100644
index 00000000..20645978
--- /dev/null
+++ b/mokoki/mingw/main/kotlin/com/javiersc/mokoki/internal/LoggerNames.mingw.kt
@@ -0,0 +1,51 @@
+package com.javiersc.mokoki.internal
+
+internal actual val fileName
+ get() = "file ${stackTrace?.fileName ?: "Unknown"}"
+
+internal actual val className
+ get() = "class ${
+ stackTrace?.className?.split(".")?.lastOrNull() ?: "Unknown"
+ }"
+
+internal actual val methodName
+ get() = "fun ${stackTrace?.methodName ?: "Unknown"}"
+
+internal actual val lineNumber
+ get() = "line ${stackTrace?.lineNumber ?: "Unknown"}"
+
+internal actual val fileLink
+ get() = "(${stackTrace?.fileName}:${stackTrace?.lineNumber})"
+
+private data class StackTraceElement(
+ val fileName: String,
+ val className: String?,
+ val methodName: String?,
+ val lineNumber: String?,
+)
+
+private val stackTrace: StackTraceElement?
+ get() =
+ try {
+ throw IllegalStateException("MOKOKI INTERNAL ERROR")
+ } catch (exception: IllegalStateException) {
+ val lines = exception.getStackTrace().toList()
+ val line =
+ lines
+ .dropWhile { !it.contains("log(com.javiersc.mokoki.Priority") }
+ .dropWhile { it.contains("log(com.javiersc.mokoki.Priority") }
+ .dropWhile { !it.contains("FUNCTION_REFERENCE") }
+ .firstOrNull()
+
+ val className: String? = line?.substringAfter('$')?.substringBefore('$')
+ val fileName: String? = className?.let { "$it.kt" }
+ val methodName: String? =
+ line?.substringBefore("\$FUNCTION_REFERENCE")?.substringAfterLast('$')
+ val lineNumber = "1"
+
+ if (fileName != null && className != null && methodName != null && lineNumber != null) {
+ StackTraceElement(fileName, className, methodName, lineNumber)
+ } else {
+ null
+ }
+ }
diff --git a/mokoki/mingw/test/kotlin/com/javiersc/mokoki/MokokiMingGWTest.mingw.kt b/mokoki/mingw/test/kotlin/com/javiersc/mokoki/MokokiMingGWTest.mingw.kt
new file mode 100644
index 00000000..9cb477f8
--- /dev/null
+++ b/mokoki/mingw/test/kotlin/com/javiersc/mokoki/MokokiMingGWTest.mingw.kt
@@ -0,0 +1,112 @@
+@file:Suppress("MaxLineLength")
+
+package com.javiersc.mokoki
+
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
+import kotlin.test.Test
+
+class MokokiMingGWTest {
+
+ private val testLogger = TestMokokiLogger(minPriority = Priority.VERBOSE)
+
+ @BeforeTest
+ fun install_logger() {
+ MokokiLogger.install(testLogger)
+ }
+
+ @AfterTest
+ fun uninstallAllLoggers() {
+ MokokiLogger.uninstallAllLoggers()
+ }
+
+ @Test
+ fun log_V() {
+ logV("Some tag") { "Some message" }
+
+ testLogger.assert(
+ """
+ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
+ │ Some tag │ VERBOSE.(MokokiMingGWTest.kt:1) │ file MokokiMingGWTest.kt │ class MokokiMingGWTest │ fun log_V │ line 1 │
+ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+ │ Some message │
+ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+ """.trimIndent(),
+ )
+ }
+
+ @Test
+ fun log_D() {
+ logD("Some tag") { "Some message" }
+
+ testLogger.assert(
+ """
+ ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
+ │ Some tag │ DEBUG.(MokokiMingGWTest.kt:1) │ file MokokiMingGWTest.kt │ class MokokiMingGWTest │ fun log_D │ line 1 │
+ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+ │ Some message │
+ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+ """.trimIndent(),
+ )
+ }
+
+ @Test
+ fun log_I() {
+ logI("Some tag") { "Some message" }
+
+ testLogger.assert(
+ """
+ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
+ │ Some tag │ INFO.(MokokiMingGWTest.kt:1) │ file MokokiMingGWTest.kt │ class MokokiMingGWTest │ fun log_I │ line 1 │
+ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+ │ Some message │
+ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+ """.trimIndent(),
+ )
+ }
+
+ @Test
+ fun log_W() {
+ logW("Some tag") { "Some message" }
+
+ testLogger.assert(
+ """
+ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
+ │ Some tag │ WARN.(MokokiMingGWTest.kt:1) │ file MokokiMingGWTest.kt │ class MokokiMingGWTest │ fun log_W │ line 1 │
+ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+ │ Some message │
+ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+ """.trimIndent(),
+ )
+ }
+
+ @Test
+ fun log_E() {
+ logE("Some tag") { "Some message" }
+
+ testLogger.assert(
+ """
+ ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
+ │ Some tag │ ERROR.(MokokiMingGWTest.kt:1) │ file MokokiMingGWTest.kt │ class MokokiMingGWTest │ fun log_E │ line 1 │
+ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+ │ Some message │
+ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+ """.trimIndent(),
+ )
+ }
+
+ @Test
+ fun log_WTF() {
+ logWTF("Some tag") { "Some message" }
+
+ testLogger.assert(
+ """
+ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
+ │ Some tag │ ASSERT.(MokokiMingGWTest.kt:1) │ file MokokiMingGWTest.kt │ class MokokiMingGWTest │ fun log_WTF │ line 1 │
+ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
+ │ Some message │
+ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+ """.trimIndent(),
+ )
+ }
+}
diff --git a/samples/android/android-core/build.gradle.kts b/samples/android/android-core/build.gradle.kts
index a785524d..4697cbfa 100644
--- a/samples/android/android-core/build.gradle.kts
+++ b/samples/android/android-core/build.gradle.kts
@@ -14,7 +14,7 @@ hubdle {
implementation(androidxAppcompat())
implementation(androidxCoreKtx())
- implementation(projects.mokokiCore)
+ implementation(projects.mokoki)
implementation(projects.mokokiSerialization)
}
}
diff --git a/samples/jvm/jvm-core/build.gradle.kts b/samples/jvm/jvm-core/build.gradle.kts
index 5c9cc9a9..67189f64 100644
--- a/samples/jvm/jvm-core/build.gradle.kts
+++ b/samples/jvm/jvm-core/build.gradle.kts
@@ -10,7 +10,7 @@ hubdle {
}
main {
dependencies {
- implementation(projects.mokokiCore)
+ implementation(projects.mokoki)
}
}
}