-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62490b4
commit 3004e24
Showing
9 changed files
with
323 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
### Intellij ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
.idea/modules.xml | ||
.idea/*.iml | ||
.idea/modules/ | ||
*.iml | ||
*.ipr | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle | ||
.gradle/ | ||
build/ | ||
|
||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
public final class co/touchlab/kermit/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 <init> ()V | ||
} | ||
|
||
public final class co/touchlab/kermit/TestConfig : co/touchlab/kermit/LoggerConfig { | ||
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/util/List;)V | ||
public final fun component1 ()Lco/touchlab/kermit/Severity; | ||
public final fun component2 ()Ljava/util/List; | ||
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/util/List;)Lco/touchlab/kermit/TestConfig; | ||
public static synthetic fun copy$default (Lco/touchlab/kermit/TestConfig;Lco/touchlab/kermit/Severity;Ljava/util/List;ILjava/lang/Object;)Lco/touchlab/kermit/TestConfig; | ||
public fun equals (Ljava/lang/Object;)Z | ||
public fun getLogWriterList ()Ljava/util/List; | ||
public fun getMinSeverity ()Lco/touchlab/kermit/Severity; | ||
public fun hashCode ()I | ||
public fun toString ()Ljava/lang/String; | ||
} | ||
|
||
public final class co/touchlab/kermit/TestLogWriter : co/touchlab/kermit/LogWriter { | ||
public fun <init> (Lco/touchlab/kermit/Severity;)V | ||
public final fun assertCount (I)V | ||
public final fun assertLast (Lkotlin/jvm/functions/Function1;)V | ||
public final fun getLogs ()Ljava/util/List; | ||
public fun isLoggable (Lco/touchlab/kermit/Severity;)Z | ||
public fun log (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V | ||
public final fun reset ()V | ||
} | ||
|
||
public final class co/touchlab/kermit/TestLogWriter$LogEntry { | ||
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V | ||
public final fun component1 ()Lco/touchlab/kermit/Severity; | ||
public final fun component2 ()Ljava/lang/String; | ||
public final fun component3 ()Ljava/lang/String; | ||
public final fun component4 ()Ljava/lang/Throwable; | ||
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)Lco/touchlab/kermit/TestLogWriter$LogEntry; | ||
public static synthetic fun copy$default (Lco/touchlab/kermit/TestLogWriter$LogEntry;Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;ILjava/lang/Object;)Lco/touchlab/kermit/TestLogWriter$LogEntry; | ||
public fun equals (Ljava/lang/Object;)Z | ||
public final fun getMessage ()Ljava/lang/String; | ||
public final fun getSeverity ()Lco/touchlab/kermit/Severity; | ||
public final fun getTag ()Ljava/lang/String; | ||
public final fun getThrowable ()Ljava/lang/Throwable; | ||
public fun hashCode ()I | ||
public fun toString ()Ljava/lang/String; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
public final class co/touchlab/kermit/TestConfig : co/touchlab/kermit/LoggerConfig { | ||
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/util/List;)V | ||
public final fun component1 ()Lco/touchlab/kermit/Severity; | ||
public final fun component2 ()Ljava/util/List; | ||
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/util/List;)Lco/touchlab/kermit/TestConfig; | ||
public static synthetic fun copy$default (Lco/touchlab/kermit/TestConfig;Lco/touchlab/kermit/Severity;Ljava/util/List;ILjava/lang/Object;)Lco/touchlab/kermit/TestConfig; | ||
public fun equals (Ljava/lang/Object;)Z | ||
public fun getLogWriterList ()Ljava/util/List; | ||
public fun getMinSeverity ()Lco/touchlab/kermit/Severity; | ||
public fun hashCode ()I | ||
public fun toString ()Ljava/lang/String; | ||
} | ||
|
||
public final class co/touchlab/kermit/TestLogWriter : co/touchlab/kermit/LogWriter { | ||
public fun <init> (Lco/touchlab/kermit/Severity;)V | ||
public final fun assertCount (I)V | ||
public final fun assertLast (Lkotlin/jvm/functions/Function1;)V | ||
public final fun getLogs ()Ljava/util/List; | ||
public fun isLoggable (Lco/touchlab/kermit/Severity;)Z | ||
public fun log (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V | ||
public final fun reset ()V | ||
} | ||
|
||
public final class co/touchlab/kermit/TestLogWriter$LogEntry { | ||
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V | ||
public final fun component1 ()Lco/touchlab/kermit/Severity; | ||
public final fun component2 ()Ljava/lang/String; | ||
public final fun component3 ()Ljava/lang/String; | ||
public final fun component4 ()Ljava/lang/Throwable; | ||
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)Lco/touchlab/kermit/TestLogWriter$LogEntry; | ||
public static synthetic fun copy$default (Lco/touchlab/kermit/TestLogWriter$LogEntry;Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;ILjava/lang/Object;)Lco/touchlab/kermit/TestLogWriter$LogEntry; | ||
public fun equals (Ljava/lang/Object;)Z | ||
public final fun getMessage ()Ljava/lang/String; | ||
public final fun getSeverity ()Lco/touchlab/kermit/Severity; | ||
public final fun getTag ()Ljava/lang/String; | ||
public final fun getThrowable ()Ljava/lang/Throwable; | ||
public fun hashCode ()I | ||
public fun toString ()Ljava/lang/String; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright (c) 2021 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. | ||
*/ | ||
|
||
plugins { | ||
id("com.android.library") | ||
kotlin("multiplatform") | ||
} | ||
|
||
val STATELY_VERSION: String by project | ||
|
||
kotlin { | ||
android { | ||
publishAllLibraryVariants() | ||
} | ||
jvm() | ||
js(BOTH) { | ||
browser() | ||
nodejs() | ||
} | ||
|
||
macosX64() | ||
macosArm64() | ||
iosX64() | ||
iosArm64() | ||
iosArm32() | ||
iosSimulatorArm64() | ||
watchosArm32() | ||
watchosArm64() | ||
watchosSimulatorArm64() | ||
watchosX86() | ||
watchosX64() | ||
tvosArm64() | ||
tvosSimulatorArm64() | ||
tvosX64() | ||
|
||
mingwX64() | ||
mingwX86() | ||
linuxX64() | ||
linuxArm32Hfp() | ||
linuxMips32() | ||
|
||
val commonMain by sourceSets.getting | ||
val commonTest by sourceSets.getting | ||
|
||
val jsMain by sourceSets.getting | ||
val jsTest by sourceSets.getting | ||
|
||
val jvmMain by sourceSets.getting { | ||
dependsOn(commonMain) | ||
} | ||
|
||
val androidMain by sourceSets.getting { | ||
dependsOn(commonMain) | ||
} | ||
|
||
commonMain.dependencies { | ||
implementation(kotlin("test-common")) | ||
implementation(project(":kermit")) | ||
implementation("co.touchlab:stately-collections:$STATELY_VERSION") | ||
} | ||
|
||
jsMain.dependencies { | ||
implementation(kotlin("stdlib-js")) | ||
implementation(kotlin("test-js")) | ||
} | ||
|
||
jvmMain.dependencies { | ||
implementation(kotlin("test")) | ||
implementation(kotlin("test-junit")) | ||
} | ||
|
||
androidMain.dependencies { | ||
implementation(kotlin("test")) | ||
implementation(kotlin("test-junit")) | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion(30) | ||
defaultConfig { | ||
minSdkVersion(15) | ||
} | ||
|
||
val main by sourceSets.getting { | ||
manifest.srcFile("src/androidMain/AndroidManifest.xml") | ||
} | ||
} | ||
|
||
tasks.register("publishWindows") { | ||
if (tasks.findByName("publish") != null && | ||
tasks.findByName("publishMingwX64PublicationToMavenRepository") != null) { | ||
dependsOn( | ||
"publishMingwX64PublicationToMavenRepository", | ||
"publishMingwX86PublicationToMavenRepository" | ||
) | ||
} | ||
} | ||
|
||
tasks.register("publishLinux") { | ||
if (tasks.findByName("publish") != null && | ||
tasks.findByName("publishLinuxMips32PublicationToMavenRepository") != null) { | ||
dependsOn("publishLinuxMips32PublicationToMavenRepository") | ||
} | ||
} | ||
|
||
apply(from = "../gradle/gradle-mvn-mpp-push.gradle") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright (c) 2021 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. | ||
--> | ||
<manifest package="co.touchlab.kermit"/> |
57 changes: 57 additions & 0 deletions
57
kermit-test/src/commonMain/kotlin/co/touchlab/kermit/TestLogWriter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2021 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 | ||
|
||
import co.touchlab.stately.collections.frozenLinkedList | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
|
||
data class TestConfig( | ||
override val minSeverity: Severity, | ||
override val logWriterList: List<LogWriter>, | ||
) : LoggerConfig | ||
|
||
class TestLogWriter(private val loggable: Severity) : LogWriter() { | ||
data class LogEntry( | ||
val severity: Severity, | ||
val message: String, | ||
val tag: String?, | ||
val throwable: Throwable? | ||
) | ||
|
||
@Suppress("DEPRECATION") | ||
private val _logs = frozenLinkedList<LogEntry>() | ||
val logs: List<LogEntry> | ||
get() = _logs.toList() | ||
|
||
fun assertCount(count: Int) { | ||
assertEquals(count, _logs.size) | ||
} | ||
|
||
fun assertLast(check: LogEntry.() -> Boolean) { | ||
assertTrue(_logs.last().check()) | ||
} | ||
|
||
fun reset() { | ||
_logs.clear() | ||
} | ||
|
||
override fun isLoggable(severity: Severity): Boolean { | ||
return severity.ordinal >= loggable.ordinal | ||
} | ||
|
||
override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { | ||
_logs.add(LogEntry(severity, message, tag, throwable)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters