From 89504c99eb24d9025831bcf00a53cd0e55a86f9d Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Fri, 19 Jun 2020 17:03:41 +1200 Subject: [PATCH 01/10] Created linuxX64 module, and updated Kotlin to 1.3.72. --- build.gradle.kts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a195817c..83f5724e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.dokka.gradle.DokkaTask import java.util.Date plugins { - kotlin("multiplatform") version "1.3.70" + kotlin("multiplatform") version "1.3.72" id("com.jfrog.bintray") version "1.8.4" id("org.jetbrains.dokka") version "0.10.0" `maven-publish` @@ -67,6 +67,7 @@ kotlin { } } } + linuxX64("linuxX64") sourceSets { commonMain { dependencies { @@ -143,7 +144,7 @@ bintray { user = "oshai"//project.hasProperty("bintrayUser") ? project.property("bintrayUser") : System.getenv("BINTRAY_USER") key = "mykey" //https://bintray.com/profile/edit // project.hasProperty("bintrayApiKey") ? project.property("bintrayApiKey") : System.getenv("BINTRAY_API_KEY") - setPublications("metadata", "jvm", "js") + setPublications("metadata", "jvm", "js", "linuxX64") publish = true //[Default: false] Whether version should be auto published after an upload pkg.apply { repo = "kotlin-logging" From 5061f55c6f7a333d35aa169768849ae93c3f7216 Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Fri, 19 Jun 2020 17:52:20 +1200 Subject: [PATCH 02/10] Implemented functionality for console logging. --- build.gradle.kts | 3 +- src/linuxX64Main/kotlin/mu/Appender.kt | 9 ++ .../kotlin/mu/ConsoleOutputAppender.kt | 15 ++ .../kotlin/mu/DefaultMessageFormatter.kt | 36 +++++ src/linuxX64Main/kotlin/mu/Formatter.kt | 14 ++ src/linuxX64Main/kotlin/mu/KLogger.kt | 129 ++++++++++++++++++ src/linuxX64Main/kotlin/mu/KMarkerFactory.kt | 8 ++ src/linuxX64Main/kotlin/mu/KotlinLogging.kt | 16 +++ .../kotlin/mu/KotlinLoggingConfiguration.kt | 8 ++ .../kotlin/mu/KotlinLoggingLevel.kt | 13 ++ src/linuxX64Main/kotlin/mu/Marker.kt | 6 + .../kotlin/mu/internal/KLoggerLinux.kt | 114 ++++++++++++++++ .../kotlin/mu/internal/MarkerLinux.kt | 8 ++ 13 files changed, 378 insertions(+), 1 deletion(-) create mode 100644 src/linuxX64Main/kotlin/mu/Appender.kt create mode 100644 src/linuxX64Main/kotlin/mu/ConsoleOutputAppender.kt create mode 100644 src/linuxX64Main/kotlin/mu/DefaultMessageFormatter.kt create mode 100644 src/linuxX64Main/kotlin/mu/Formatter.kt create mode 100644 src/linuxX64Main/kotlin/mu/KLogger.kt create mode 100644 src/linuxX64Main/kotlin/mu/KMarkerFactory.kt create mode 100644 src/linuxX64Main/kotlin/mu/KotlinLogging.kt create mode 100644 src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt create mode 100644 src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt create mode 100644 src/linuxX64Main/kotlin/mu/Marker.kt create mode 100644 src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt create mode 100644 src/linuxX64Main/kotlin/mu/internal/MarkerLinux.kt diff --git a/build.gradle.kts b/build.gradle.kts index 83f5724e..91d29d8e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -136,7 +136,8 @@ publishing { url.set("http://github.com/MicroUtils/kotlin-logging/tree/master") } } - artifact(tasks["javadocJar"]) + // TODO: Fix generation of Java Doc Jars. +// artifact(tasks["javadocJar"]) } } diff --git a/src/linuxX64Main/kotlin/mu/Appender.kt b/src/linuxX64Main/kotlin/mu/Appender.kt new file mode 100644 index 00000000..9a1947b0 --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/Appender.kt @@ -0,0 +1,9 @@ +package mu + +interface Appender { + fun trace(message: Any?) + fun debug(message: Any?) + fun info(message: Any?) + fun warn(message: Any?) + fun error(message: Any?) +} diff --git a/src/linuxX64Main/kotlin/mu/ConsoleOutputAppender.kt b/src/linuxX64Main/kotlin/mu/ConsoleOutputAppender.kt new file mode 100644 index 00000000..b3b004c0 --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/ConsoleOutputAppender.kt @@ -0,0 +1,15 @@ +package mu + +import platform.posix.fprintf +import platform.posix.stderr + +object ConsoleOutputAppender : Appender { + override fun trace(message: Any?) = println(message) + override fun debug(message: Any?) = println(message) + override fun info(message: Any?) = println(message) + override fun warn(message: Any?) = println(message) + + override fun error(message: Any?) { + fprintf(stderr, "$message\n") + } +} diff --git a/src/linuxX64Main/kotlin/mu/DefaultMessageFormatter.kt b/src/linuxX64Main/kotlin/mu/DefaultMessageFormatter.kt new file mode 100644 index 00000000..35de1cbe --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/DefaultMessageFormatter.kt @@ -0,0 +1,36 @@ +package mu + +import mu.internal.toStringSafe + +object DefaultMessageFormatter : Formatter { + override fun formatMessage(level: KotlinLoggingLevel, loggerName: String, msg: () -> Any?) = + "${level.name}: [$loggerName] ${msg.toStringSafe()}" + + override fun formatMessage(level: KotlinLoggingLevel, loggerName: String, t: Throwable?, msg: () -> Any?) = + "${level.name}: [$loggerName] ${msg.toStringSafe()}${t.throwableToString()}" + + override fun formatMessage(level: KotlinLoggingLevel, loggerName: String, marker: Marker?, msg: () -> Any?) = + "${level.name}: [$loggerName] ${marker?.getName()} ${msg.toStringSafe()}" + + override fun formatMessage( + level: KotlinLoggingLevel, + loggerName: String, + marker: Marker?, + t: Throwable?, + msg: () -> Any? + ) = + "${level.name}: [$loggerName] ${marker?.getName()} ${msg.toStringSafe()}${t.throwableToString()}" + + private fun Throwable?.throwableToString(): String { + if (this == null) { + return "" + } + var msg = "" + var current = this + while (current != null && current.cause != current) { + msg += ", Caused by: '${current.message}'" + current = current.cause + } + return msg + } +} diff --git a/src/linuxX64Main/kotlin/mu/Formatter.kt b/src/linuxX64Main/kotlin/mu/Formatter.kt new file mode 100644 index 00000000..55489f19 --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/Formatter.kt @@ -0,0 +1,14 @@ +package mu + +interface Formatter { + fun formatMessage(level: KotlinLoggingLevel, loggerName: String, msg: () -> Any?): Any? + fun formatMessage(level: KotlinLoggingLevel, loggerName: String, t: Throwable?, msg: () -> Any?): Any? + fun formatMessage(level: KotlinLoggingLevel, loggerName: String, marker: Marker?, msg: () -> Any?): Any? + fun formatMessage( + level: KotlinLoggingLevel, + loggerName: String, + marker: Marker?, + t: Throwable?, + msg: () -> Any? + ): Any? +} diff --git a/src/linuxX64Main/kotlin/mu/KLogger.kt b/src/linuxX64Main/kotlin/mu/KLogger.kt new file mode 100644 index 00000000..7ea915a6 --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/KLogger.kt @@ -0,0 +1,129 @@ +package mu + +actual interface KLogger { + + /** + * Lazy add a log message if isTraceEnabled is true + */ + actual fun trace(msg: () -> Any?) + + /** + * Lazy add a log message if isDebugEnabled is true + */ + actual fun debug(msg: () -> Any?) + + /** + * Lazy add a log message if isInfoEnabled is true + */ + actual fun info(msg: () -> Any?) + + /** + * Lazy add a log message if isWarnEnabled is true + */ + actual fun warn(msg: () -> Any?) + + /** + * Lazy add a log message if isErrorEnabled is true + */ + actual fun error(msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isTraceEnabled is true + */ + actual fun trace(t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isDebugEnabled is true + */ + actual fun debug(t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isInfoEnabled is true + */ + actual fun info(t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isWarnEnabled is true + */ + actual fun warn(t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isErrorEnabled is true + */ + actual fun error(t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message if isTraceEnabled is true + */ + actual fun trace(marker: Marker?, msg: () -> Any?) + + /** + * Lazy add a log message if isDebugEnabled is true + */ + actual fun debug(marker: Marker?, msg: () -> Any?) + + /** + * Lazy add a log message if isInfoEnabled is true + */ + actual fun info(marker: Marker?, msg: () -> Any?) + + /** + * Lazy add a log message if isWarnEnabled is true + */ + actual fun warn(marker: Marker?, msg: () -> Any?) + + /** + * Lazy add a log message if isErrorEnabled is true + */ + actual fun error(marker: Marker?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isTraceEnabled is true + */ + actual fun trace(marker: Marker?, t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isDebugEnabled is true + */ + actual fun debug(marker: Marker?, t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isInfoEnabled is true + */ + actual fun info(marker: Marker?, t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isWarnEnabled is true + */ + actual fun warn(marker: Marker?, t: Throwable?, msg: () -> Any?) + + /** + * Lazy add a log message with throwable payload if isErrorEnabled is true + */ + actual fun error(marker: Marker?, t: Throwable?, msg: () -> Any?) + + /** + * Add a log message with all the supplied parameters along with method name + */ + actual fun entry(vararg argArray: Any?) + + /** + * Add log message indicating exit of a method + */ + actual fun exit() + + /** + * Add a log message with the return value of a method + */ + actual fun exit(result: T): T where T : Any? + + /** + * Add a log message indicating an exception will be thrown along with the stack trace. + */ + actual fun throwing(throwable: T): T where T : Throwable + + /** + * Add a log message indicating an exception is caught along with the stack trace. + */ + actual fun catching(throwable: T) where T : Throwable +} diff --git a/src/linuxX64Main/kotlin/mu/KMarkerFactory.kt b/src/linuxX64Main/kotlin/mu/KMarkerFactory.kt new file mode 100644 index 00000000..037eacea --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/KMarkerFactory.kt @@ -0,0 +1,8 @@ +package mu + +import mu.internal.MarkerLinux + +actual object KMarkerFactory { + + actual fun getMarker(name: String): Marker = MarkerLinux(name) +} diff --git a/src/linuxX64Main/kotlin/mu/KotlinLogging.kt b/src/linuxX64Main/kotlin/mu/KotlinLogging.kt new file mode 100644 index 00000000..b249433c --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/KotlinLogging.kt @@ -0,0 +1,16 @@ +package mu + +import mu.internal.KLoggerLinux + + +actual object KotlinLogging { + /** + * This method allow defining the logger in a file in the following way: + * ``` + * val logger = KotlinLogging.logger {} + * ``` + */ + actual fun logger(func: () -> Unit): KLogger = KLoggerLinux(func::class.qualifiedName ?: "") + + actual fun logger(name: String): KLogger = KLoggerLinux(name) +} diff --git a/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt b/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt new file mode 100644 index 00000000..5cb84c1f --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt @@ -0,0 +1,8 @@ +package mu + +object KotlinLoggingConfiguration { + var LOG_LEVEL = KotlinLoggingLevel.INFO + var APPENDER: Appender = ConsoleOutputAppender + var FORMATTER: Formatter = DefaultMessageFormatter + +} diff --git a/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt b/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt new file mode 100644 index 00000000..0c5d0d7a --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt @@ -0,0 +1,13 @@ +package mu + +import mu.KotlinLoggingConfiguration.LOG_LEVEL + +enum class KotlinLoggingLevel { + TRACE, + DEBUG, + INFO, + WARN, + ERROR +} + +fun KotlinLoggingLevel.isLoggingEnabled() = this.ordinal >= LOG_LEVEL.ordinal diff --git a/src/linuxX64Main/kotlin/mu/Marker.kt b/src/linuxX64Main/kotlin/mu/Marker.kt new file mode 100644 index 00000000..eca0daf6 --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/Marker.kt @@ -0,0 +1,6 @@ +package mu + +actual interface Marker { + + actual fun getName(): String +} diff --git a/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt b/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt new file mode 100644 index 00000000..b42dcc9d --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt @@ -0,0 +1,114 @@ +package mu.internal + +import mu.KLogger +import mu.KotlinLoggingConfiguration.APPENDER +import mu.KotlinLoggingConfiguration.FORMATTER +import mu.KotlinLoggingLevel +import mu.KotlinLoggingLevel.DEBUG +import mu.KotlinLoggingLevel.ERROR +import mu.KotlinLoggingLevel.INFO +import mu.KotlinLoggingLevel.TRACE +import mu.KotlinLoggingLevel.WARN +import mu.Marker +import mu.isLoggingEnabled + +internal class KLoggerLinux( + private val loggerName: String +) : KLogger { + + override fun trace(msg: () -> Any?) = TRACE.logIfEnabled(msg, APPENDER::trace) + + override fun debug(msg: () -> Any?) = DEBUG.logIfEnabled(msg, APPENDER::debug) + + override fun info(msg: () -> Any?) = INFO.logIfEnabled(msg, APPENDER::info) + + override fun warn(msg: () -> Any?) = WARN.logIfEnabled(msg, APPENDER::warn) + + override fun error(msg: () -> Any?) = ERROR.logIfEnabled(msg, APPENDER::error) + + override fun trace(t: Throwable?, msg: () -> Any?) = TRACE.logIfEnabled(msg, t, APPENDER::trace) + + override fun debug(t: Throwable?, msg: () -> Any?) = DEBUG.logIfEnabled(msg, t, APPENDER::debug) + + override fun info(t: Throwable?, msg: () -> Any?) = INFO.logIfEnabled(msg, t, APPENDER::info) + + override fun warn(t: Throwable?, msg: () -> Any?) = WARN.logIfEnabled(msg, t, APPENDER::warn) + + override fun error(t: Throwable?, msg: () -> Any?) = ERROR.logIfEnabled(msg, t, APPENDER::error) + + override fun trace(marker: Marker?, msg: () -> Any?) = TRACE.logIfEnabled(marker, msg, APPENDER::trace) + + override fun debug(marker: Marker?, msg: () -> Any?) = DEBUG.logIfEnabled(marker, msg, APPENDER::debug) + + override fun info(marker: Marker?, msg: () -> Any?) = INFO.logIfEnabled(marker, msg, APPENDER::info) + + override fun warn(marker: Marker?, msg: () -> Any?) = WARN.logIfEnabled(marker, msg, APPENDER::warn) + + override fun error(marker: Marker?, msg: () -> Any?) = ERROR.logIfEnabled(marker, msg, APPENDER::error) + + override fun trace(marker: Marker?, t: Throwable?, msg: () -> Any?) = + TRACE.logIfEnabled(marker, msg, t, APPENDER::trace) + + override fun debug(marker: Marker?, t: Throwable?, msg: () -> Any?) = + DEBUG.logIfEnabled(marker, msg, t, APPENDER::debug) + + override fun info(marker: Marker?, t: Throwable?, msg: () -> Any?) = + INFO.logIfEnabled(marker, msg, t, APPENDER::info) + + override fun warn(marker: Marker?, t: Throwable?, msg: () -> Any?) = + WARN.logIfEnabled(marker, msg, t, APPENDER::warn) + + override fun error(marker: Marker?, t: Throwable?, msg: () -> Any?) = + ERROR.logIfEnabled(marker, msg, t, APPENDER::error) + + private fun KotlinLoggingLevel.logIfEnabled(msg: () -> Any?, logFunction: (Any?) -> Unit) { + if (isLoggingEnabled()) { + logFunction(FORMATTER.formatMessage(this, loggerName, msg)) + } + } + + private fun KotlinLoggingLevel.logIfEnabled(msg: () -> Any?, t: Throwable?, logFunction: (Any?) -> Unit) { + if (isLoggingEnabled()) { + logFunction(FORMATTER.formatMessage(this, loggerName, t, msg)) + } + } + + private fun KotlinLoggingLevel.logIfEnabled(marker: Marker?, msg: () -> Any?, logFunction: (Any?) -> Unit) { + if (isLoggingEnabled()) { + logFunction(FORMATTER.formatMessage(this, loggerName, marker, msg)) + } + } + + private fun KotlinLoggingLevel.logIfEnabled( + marker: Marker?, + msg: () -> Any?, + t: Throwable?, + logFunction: (Any?) -> Unit + ) { + if (isLoggingEnabled()) { + logFunction(FORMATTER.formatMessage(this, loggerName, marker, t, msg)) + } + } + + override fun entry(vararg argArray: Any?) { + TRACE.logIfEnabled({ "entry($argArray)" }, APPENDER::trace) + } + + override fun exit() { + TRACE.logIfEnabled({ "exit()" }, APPENDER::trace) + } + + override fun exit(result: T): T { + TRACE.logIfEnabled({ "exit($result)" }, APPENDER::trace) + return result + } + + override fun throwing(throwable: T): T { + ERROR.logIfEnabled({ "throwing($throwable" }, throwable, APPENDER::error) + return throwable + } + + override fun catching(throwable: T) { + ERROR.logIfEnabled({ "catching($throwable" }, throwable, APPENDER::error) + } +} diff --git a/src/linuxX64Main/kotlin/mu/internal/MarkerLinux.kt b/src/linuxX64Main/kotlin/mu/internal/MarkerLinux.kt new file mode 100644 index 00000000..0825812c --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/internal/MarkerLinux.kt @@ -0,0 +1,8 @@ +package mu.internal + +import mu.Marker + +internal class MarkerLinux(private val name: String) : Marker { + + override fun getName(): String = this.name +} From cb67d01055e85607910c63ca31355857e11cddbd Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Sat, 20 Jun 2020 16:28:47 +1200 Subject: [PATCH 03/10] Added publishing to GitHub Packages. --- .gitignore | 1 + build.gradle.kts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/.gitignore b/.gitignore index eb56374d..c1ccbea1 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ fabric.properties # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +github_packages.properties diff --git a/build.gradle.kts b/build.gradle.kts index 91d29d8e..f049ba10 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import org.jetbrains.dokka.gradle.DokkaTask import java.util.Date +import java.util.Properties plugins { kotlin("multiplatform") version "1.3.72" @@ -111,6 +112,17 @@ kotlin { } publishing { + repositories { + maven { + val settings = fetchGitHubPackagesSettings() + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/${settings.owner}/${settings.repository}") + credentials { + username = settings.user + password = settings.token + } + } + } publications.withType { pom { name.set("kotlin-logging") @@ -172,3 +184,23 @@ bintray { } } } + +data class GitHubPackagesSettings(val user: String, val token: String, val owner: String, val repository: String) + +fun fetchGitHubPackagesSettings(): GitHubPackagesSettings { + var owner = "" + var repository = "" + var user = "" + var token = "" + val properties = Properties() + file("github_packages.properties").bufferedReader().use { br -> + with(properties) { + load(br) + owner = getProperty("gpr.owner") + repository = getProperty("gpr.repository") + user = getProperty("gpr.user") + token = getProperty("gpr.token") + } + } + return GitHubPackagesSettings(user = user, token = token, owner = owner, repository = repository) +} From 22e1a3fb1af1df173bc1b8605107add58a6e3d2d Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Sun, 21 Jun 2020 14:40:19 +1200 Subject: [PATCH 04/10] Applied workaround for the github_packages.properties file in the build file. --- .gitignore | 1 + build.gradle.kts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index c1ccbea1..2ae05eba 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ fabric.properties hs_err_pid* github_packages.properties +github_packages.properties.old diff --git a/build.gradle.kts b/build.gradle.kts index f049ba10..e54bbc6d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -193,13 +193,16 @@ fun fetchGitHubPackagesSettings(): GitHubPackagesSettings { var user = "" var token = "" val properties = Properties() - file("github_packages.properties").bufferedReader().use { br -> - with(properties) { - load(br) - owner = getProperty("gpr.owner") - repository = getProperty("gpr.repository") - user = getProperty("gpr.user") - token = getProperty("gpr.token") + val filename = "github_packages.properties" + if (file(filename).exists()) { + file(filename).bufferedReader().use { br -> + with(properties) { + load(br) + owner = getProperty("gpr.owner") + repository = getProperty("gpr.repository") + user = getProperty("gpr.user") + token = getProperty("gpr.token") + } } } return GitHubPackagesSettings(user = user, token = token, owner = owner, repository = repository) From bda6d610d7db412449cff6cee409ccaf46f978ac Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Mon, 22 Jun 2020 11:40:33 +1200 Subject: [PATCH 05/10] Enabled generation of Java Doc JARs. --- build.gradle.kts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e54bbc6d..04c579a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -148,8 +148,7 @@ publishing { url.set("http://github.com/MicroUtils/kotlin-logging/tree/master") } } - // TODO: Fix generation of Java Doc Jars. -// artifact(tasks["javadocJar"]) + artifact(tasks["javadocJar"]) } } From 16d190b24d6fe7e7f2c701f5e2f6c89fc7173368 Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Mon, 22 Jun 2020 14:26:14 +1200 Subject: [PATCH 06/10] Created Appender interface in common module. --- src/{jsMain => commonMain}/kotlin/mu/Appender.kt | 0 src/linuxX64Main/kotlin/mu/Appender.kt | 9 --------- 2 files changed, 9 deletions(-) rename src/{jsMain => commonMain}/kotlin/mu/Appender.kt (100%) delete mode 100644 src/linuxX64Main/kotlin/mu/Appender.kt diff --git a/src/jsMain/kotlin/mu/Appender.kt b/src/commonMain/kotlin/mu/Appender.kt similarity index 100% rename from src/jsMain/kotlin/mu/Appender.kt rename to src/commonMain/kotlin/mu/Appender.kt diff --git a/src/linuxX64Main/kotlin/mu/Appender.kt b/src/linuxX64Main/kotlin/mu/Appender.kt deleted file mode 100644 index 9a1947b0..00000000 --- a/src/linuxX64Main/kotlin/mu/Appender.kt +++ /dev/null @@ -1,9 +0,0 @@ -package mu - -interface Appender { - fun trace(message: Any?) - fun debug(message: Any?) - fun info(message: Any?) - fun warn(message: Any?) - fun error(message: Any?) -} From 0520230e6dcb1acbd92134af0ddbbf1cce7e2211 Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Tue, 23 Jun 2020 09:18:02 +1200 Subject: [PATCH 07/10] Used AtomicReference for all properties in KotlinLoggingConfiguration.kt. --- build.gradle.kts | 2 +- .../kotlin/mu/KotlinLoggingConfiguration.kt | 9 +-- .../kotlin/mu/KotlinLoggingLevel.kt | 4 +- .../kotlin/mu/internal/KLoggerLinux.kt | 62 +++++++++---------- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 04c579a3..8862b5ff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -156,7 +156,7 @@ bintray { user = "oshai"//project.hasProperty("bintrayUser") ? project.property("bintrayUser") : System.getenv("BINTRAY_USER") key = "mykey" //https://bintray.com/profile/edit // project.hasProperty("bintrayApiKey") ? project.property("bintrayApiKey") : System.getenv("BINTRAY_API_KEY") - setPublications("metadata", "jvm", "js", "linuxX64") + setPublications("metadata", "jvm", "js") publish = true //[Default: false] Whether version should be auto published after an upload pkg.apply { repo = "kotlin-logging" diff --git a/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt b/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt index 5cb84c1f..891ec4eb 100644 --- a/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt +++ b/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt @@ -1,8 +1,9 @@ package mu -object KotlinLoggingConfiguration { - var LOG_LEVEL = KotlinLoggingLevel.INFO - var APPENDER: Appender = ConsoleOutputAppender - var FORMATTER: Formatter = DefaultMessageFormatter +import kotlin.native.concurrent.AtomicReference +object KotlinLoggingConfiguration { + val logLevel: AtomicReference = AtomicReference(KotlinLoggingLevel.INFO) + val appender: AtomicReference = AtomicReference(ConsoleOutputAppender) + val formatter: AtomicReference = AtomicReference(DefaultMessageFormatter) } diff --git a/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt b/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt index 0c5d0d7a..a653c63a 100644 --- a/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt +++ b/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt @@ -1,6 +1,6 @@ package mu -import mu.KotlinLoggingConfiguration.LOG_LEVEL +import mu.KotlinLoggingConfiguration.logLevel enum class KotlinLoggingLevel { TRACE, @@ -10,4 +10,4 @@ enum class KotlinLoggingLevel { ERROR } -fun KotlinLoggingLevel.isLoggingEnabled() = this.ordinal >= LOG_LEVEL.ordinal +fun KotlinLoggingLevel.isLoggingEnabled() = this.ordinal >= logLevel.value.ordinal diff --git a/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt b/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt index b42dcc9d..69336eab 100644 --- a/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt +++ b/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt @@ -1,8 +1,8 @@ package mu.internal import mu.KLogger -import mu.KotlinLoggingConfiguration.APPENDER -import mu.KotlinLoggingConfiguration.FORMATTER +import mu.KotlinLoggingConfiguration.appender +import mu.KotlinLoggingConfiguration.formatter import mu.KotlinLoggingLevel import mu.KotlinLoggingLevel.DEBUG import mu.KotlinLoggingLevel.ERROR @@ -16,66 +16,66 @@ internal class KLoggerLinux( private val loggerName: String ) : KLogger { - override fun trace(msg: () -> Any?) = TRACE.logIfEnabled(msg, APPENDER::trace) + override fun trace(msg: () -> Any?) = TRACE.logIfEnabled(msg, appender.value::trace) - override fun debug(msg: () -> Any?) = DEBUG.logIfEnabled(msg, APPENDER::debug) + override fun debug(msg: () -> Any?) = DEBUG.logIfEnabled(msg, appender.value::debug) - override fun info(msg: () -> Any?) = INFO.logIfEnabled(msg, APPENDER::info) + override fun info(msg: () -> Any?) = INFO.logIfEnabled(msg, appender.value::info) - override fun warn(msg: () -> Any?) = WARN.logIfEnabled(msg, APPENDER::warn) + override fun warn(msg: () -> Any?) = WARN.logIfEnabled(msg, appender.value::warn) - override fun error(msg: () -> Any?) = ERROR.logIfEnabled(msg, APPENDER::error) + override fun error(msg: () -> Any?) = ERROR.logIfEnabled(msg, appender.value::error) - override fun trace(t: Throwable?, msg: () -> Any?) = TRACE.logIfEnabled(msg, t, APPENDER::trace) + override fun trace(t: Throwable?, msg: () -> Any?) = TRACE.logIfEnabled(msg, t, appender.value::trace) - override fun debug(t: Throwable?, msg: () -> Any?) = DEBUG.logIfEnabled(msg, t, APPENDER::debug) + override fun debug(t: Throwable?, msg: () -> Any?) = DEBUG.logIfEnabled(msg, t, appender.value::debug) - override fun info(t: Throwable?, msg: () -> Any?) = INFO.logIfEnabled(msg, t, APPENDER::info) + override fun info(t: Throwable?, msg: () -> Any?) = INFO.logIfEnabled(msg, t, appender.value::info) - override fun warn(t: Throwable?, msg: () -> Any?) = WARN.logIfEnabled(msg, t, APPENDER::warn) + override fun warn(t: Throwable?, msg: () -> Any?) = WARN.logIfEnabled(msg, t, appender.value::warn) - override fun error(t: Throwable?, msg: () -> Any?) = ERROR.logIfEnabled(msg, t, APPENDER::error) + override fun error(t: Throwable?, msg: () -> Any?) = ERROR.logIfEnabled(msg, t, appender.value::error) - override fun trace(marker: Marker?, msg: () -> Any?) = TRACE.logIfEnabled(marker, msg, APPENDER::trace) + override fun trace(marker: Marker?, msg: () -> Any?) = TRACE.logIfEnabled(marker, msg, appender.value::trace) - override fun debug(marker: Marker?, msg: () -> Any?) = DEBUG.logIfEnabled(marker, msg, APPENDER::debug) + override fun debug(marker: Marker?, msg: () -> Any?) = DEBUG.logIfEnabled(marker, msg, appender.value::debug) - override fun info(marker: Marker?, msg: () -> Any?) = INFO.logIfEnabled(marker, msg, APPENDER::info) + override fun info(marker: Marker?, msg: () -> Any?) = INFO.logIfEnabled(marker, msg, appender.value::info) - override fun warn(marker: Marker?, msg: () -> Any?) = WARN.logIfEnabled(marker, msg, APPENDER::warn) + override fun warn(marker: Marker?, msg: () -> Any?) = WARN.logIfEnabled(marker, msg, appender.value::warn) - override fun error(marker: Marker?, msg: () -> Any?) = ERROR.logIfEnabled(marker, msg, APPENDER::error) + override fun error(marker: Marker?, msg: () -> Any?) = ERROR.logIfEnabled(marker, msg, appender.value::error) override fun trace(marker: Marker?, t: Throwable?, msg: () -> Any?) = - TRACE.logIfEnabled(marker, msg, t, APPENDER::trace) + TRACE.logIfEnabled(marker, msg, t, appender.value::trace) override fun debug(marker: Marker?, t: Throwable?, msg: () -> Any?) = - DEBUG.logIfEnabled(marker, msg, t, APPENDER::debug) + DEBUG.logIfEnabled(marker, msg, t, appender.value::debug) override fun info(marker: Marker?, t: Throwable?, msg: () -> Any?) = - INFO.logIfEnabled(marker, msg, t, APPENDER::info) + INFO.logIfEnabled(marker, msg, t, appender.value::info) override fun warn(marker: Marker?, t: Throwable?, msg: () -> Any?) = - WARN.logIfEnabled(marker, msg, t, APPENDER::warn) + WARN.logIfEnabled(marker, msg, t, appender.value::warn) override fun error(marker: Marker?, t: Throwable?, msg: () -> Any?) = - ERROR.logIfEnabled(marker, msg, t, APPENDER::error) + ERROR.logIfEnabled(marker, msg, t, appender.value::error) private fun KotlinLoggingLevel.logIfEnabled(msg: () -> Any?, logFunction: (Any?) -> Unit) { if (isLoggingEnabled()) { - logFunction(FORMATTER.formatMessage(this, loggerName, msg)) + logFunction(formatter.value.formatMessage(this, loggerName, msg)) } } private fun KotlinLoggingLevel.logIfEnabled(msg: () -> Any?, t: Throwable?, logFunction: (Any?) -> Unit) { if (isLoggingEnabled()) { - logFunction(FORMATTER.formatMessage(this, loggerName, t, msg)) + logFunction(formatter.value.formatMessage(this, loggerName, t, msg)) } } private fun KotlinLoggingLevel.logIfEnabled(marker: Marker?, msg: () -> Any?, logFunction: (Any?) -> Unit) { if (isLoggingEnabled()) { - logFunction(FORMATTER.formatMessage(this, loggerName, marker, msg)) + logFunction(formatter.value.formatMessage(this, loggerName, marker, msg)) } } @@ -86,29 +86,29 @@ internal class KLoggerLinux( logFunction: (Any?) -> Unit ) { if (isLoggingEnabled()) { - logFunction(FORMATTER.formatMessage(this, loggerName, marker, t, msg)) + logFunction(formatter.value.formatMessage(this, loggerName, marker, t, msg)) } } override fun entry(vararg argArray: Any?) { - TRACE.logIfEnabled({ "entry($argArray)" }, APPENDER::trace) + TRACE.logIfEnabled({ "entry($argArray)" }, appender.value::trace) } override fun exit() { - TRACE.logIfEnabled({ "exit()" }, APPENDER::trace) + TRACE.logIfEnabled({ "exit()" }, appender.value::trace) } override fun exit(result: T): T { - TRACE.logIfEnabled({ "exit($result)" }, APPENDER::trace) + TRACE.logIfEnabled({ "exit($result)" }, appender.value::trace) return result } override fun throwing(throwable: T): T { - ERROR.logIfEnabled({ "throwing($throwable" }, throwable, APPENDER::error) + ERROR.logIfEnabled({ "throwing($throwable" }, throwable, appender.value::error) return throwable } override fun catching(throwable: T) { - ERROR.logIfEnabled({ "catching($throwable" }, throwable, APPENDER::error) + ERROR.logIfEnabled({ "catching($throwable" }, throwable, appender.value::error) } } From 83f4245dd7be02cd313f0a2d41d9309f190b4029 Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Tue, 23 Jun 2020 09:20:28 +1200 Subject: [PATCH 08/10] Added Appender.kt back to js, and linuxX64 modules. --- src/{commonMain => jsMain}/kotlin/mu/Appender.kt | 0 src/linuxX64Main/kotlin/mu/Appender.kt | 9 +++++++++ 2 files changed, 9 insertions(+) rename src/{commonMain => jsMain}/kotlin/mu/Appender.kt (100%) create mode 100644 src/linuxX64Main/kotlin/mu/Appender.kt diff --git a/src/commonMain/kotlin/mu/Appender.kt b/src/jsMain/kotlin/mu/Appender.kt similarity index 100% rename from src/commonMain/kotlin/mu/Appender.kt rename to src/jsMain/kotlin/mu/Appender.kt diff --git a/src/linuxX64Main/kotlin/mu/Appender.kt b/src/linuxX64Main/kotlin/mu/Appender.kt new file mode 100644 index 00000000..9a1947b0 --- /dev/null +++ b/src/linuxX64Main/kotlin/mu/Appender.kt @@ -0,0 +1,9 @@ +package mu + +interface Appender { + fun trace(message: Any?) + fun debug(message: Any?) + fun info(message: Any?) + fun warn(message: Any?) + fun error(message: Any?) +} From c197ddb4b9784ed2e03862ea56b78ee4029a2b14 Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Thu, 25 Jun 2020 11:28:09 +1200 Subject: [PATCH 09/10] Adjusted encapsulation with KotlinLoggingConfiguration.kt. --- .../kotlin/mu/KotlinLoggingConfiguration.kt | 22 ++++++- .../kotlin/mu/KotlinLoggingLevel.kt | 2 +- .../kotlin/mu/internal/KLoggerLinux.kt | 58 +++++++++---------- 3 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt b/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt index 891ec4eb..4eb1da13 100644 --- a/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt +++ b/src/linuxX64Main/kotlin/mu/KotlinLoggingConfiguration.kt @@ -2,8 +2,24 @@ package mu import kotlin.native.concurrent.AtomicReference +@Suppress("ObjectPropertyName") object KotlinLoggingConfiguration { - val logLevel: AtomicReference = AtomicReference(KotlinLoggingLevel.INFO) - val appender: AtomicReference = AtomicReference(ConsoleOutputAppender) - val formatter: AtomicReference = AtomicReference(DefaultMessageFormatter) + private val _logLevel = AtomicReference(KotlinLoggingLevel.INFO) + var logLevel: KotlinLoggingLevel + get() = _logLevel.value + set(value) { + _logLevel.value = value + } + private val _appender = AtomicReference(ConsoleOutputAppender) + var appender: Appender + get() = _appender.value + set(value) { + _appender.value = value + } + private val _formatter = AtomicReference(DefaultMessageFormatter) + var formatter: Formatter + get() = _formatter.value + set(value) { + _formatter.value = value + } } diff --git a/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt b/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt index a653c63a..e70713e2 100644 --- a/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt +++ b/src/linuxX64Main/kotlin/mu/KotlinLoggingLevel.kt @@ -10,4 +10,4 @@ enum class KotlinLoggingLevel { ERROR } -fun KotlinLoggingLevel.isLoggingEnabled() = this.ordinal >= logLevel.value.ordinal +fun KotlinLoggingLevel.isLoggingEnabled() = this.ordinal >= logLevel.ordinal diff --git a/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt b/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt index 69336eab..2b38668d 100644 --- a/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt +++ b/src/linuxX64Main/kotlin/mu/internal/KLoggerLinux.kt @@ -16,66 +16,66 @@ internal class KLoggerLinux( private val loggerName: String ) : KLogger { - override fun trace(msg: () -> Any?) = TRACE.logIfEnabled(msg, appender.value::trace) + override fun trace(msg: () -> Any?) = TRACE.logIfEnabled(msg, appender::trace) - override fun debug(msg: () -> Any?) = DEBUG.logIfEnabled(msg, appender.value::debug) + override fun debug(msg: () -> Any?) = DEBUG.logIfEnabled(msg, appender::debug) - override fun info(msg: () -> Any?) = INFO.logIfEnabled(msg, appender.value::info) + override fun info(msg: () -> Any?) = INFO.logIfEnabled(msg, appender::info) - override fun warn(msg: () -> Any?) = WARN.logIfEnabled(msg, appender.value::warn) + override fun warn(msg: () -> Any?) = WARN.logIfEnabled(msg, appender::warn) - override fun error(msg: () -> Any?) = ERROR.logIfEnabled(msg, appender.value::error) + override fun error(msg: () -> Any?) = ERROR.logIfEnabled(msg, appender::error) - override fun trace(t: Throwable?, msg: () -> Any?) = TRACE.logIfEnabled(msg, t, appender.value::trace) + override fun trace(t: Throwable?, msg: () -> Any?) = TRACE.logIfEnabled(msg, t, appender::trace) - override fun debug(t: Throwable?, msg: () -> Any?) = DEBUG.logIfEnabled(msg, t, appender.value::debug) + override fun debug(t: Throwable?, msg: () -> Any?) = DEBUG.logIfEnabled(msg, t, appender::debug) - override fun info(t: Throwable?, msg: () -> Any?) = INFO.logIfEnabled(msg, t, appender.value::info) + override fun info(t: Throwable?, msg: () -> Any?) = INFO.logIfEnabled(msg, t, appender::info) - override fun warn(t: Throwable?, msg: () -> Any?) = WARN.logIfEnabled(msg, t, appender.value::warn) + override fun warn(t: Throwable?, msg: () -> Any?) = WARN.logIfEnabled(msg, t, appender::warn) - override fun error(t: Throwable?, msg: () -> Any?) = ERROR.logIfEnabled(msg, t, appender.value::error) + override fun error(t: Throwable?, msg: () -> Any?) = ERROR.logIfEnabled(msg, t, appender::error) - override fun trace(marker: Marker?, msg: () -> Any?) = TRACE.logIfEnabled(marker, msg, appender.value::trace) + override fun trace(marker: Marker?, msg: () -> Any?) = TRACE.logIfEnabled(marker, msg, appender::trace) - override fun debug(marker: Marker?, msg: () -> Any?) = DEBUG.logIfEnabled(marker, msg, appender.value::debug) + override fun debug(marker: Marker?, msg: () -> Any?) = DEBUG.logIfEnabled(marker, msg, appender::debug) - override fun info(marker: Marker?, msg: () -> Any?) = INFO.logIfEnabled(marker, msg, appender.value::info) + override fun info(marker: Marker?, msg: () -> Any?) = INFO.logIfEnabled(marker, msg, appender::info) - override fun warn(marker: Marker?, msg: () -> Any?) = WARN.logIfEnabled(marker, msg, appender.value::warn) + override fun warn(marker: Marker?, msg: () -> Any?) = WARN.logIfEnabled(marker, msg, appender::warn) - override fun error(marker: Marker?, msg: () -> Any?) = ERROR.logIfEnabled(marker, msg, appender.value::error) + override fun error(marker: Marker?, msg: () -> Any?) = ERROR.logIfEnabled(marker, msg, appender::error) override fun trace(marker: Marker?, t: Throwable?, msg: () -> Any?) = - TRACE.logIfEnabled(marker, msg, t, appender.value::trace) + TRACE.logIfEnabled(marker, msg, t, appender::trace) override fun debug(marker: Marker?, t: Throwable?, msg: () -> Any?) = - DEBUG.logIfEnabled(marker, msg, t, appender.value::debug) + DEBUG.logIfEnabled(marker, msg, t, appender::debug) override fun info(marker: Marker?, t: Throwable?, msg: () -> Any?) = - INFO.logIfEnabled(marker, msg, t, appender.value::info) + INFO.logIfEnabled(marker, msg, t, appender::info) override fun warn(marker: Marker?, t: Throwable?, msg: () -> Any?) = - WARN.logIfEnabled(marker, msg, t, appender.value::warn) + WARN.logIfEnabled(marker, msg, t, appender::warn) override fun error(marker: Marker?, t: Throwable?, msg: () -> Any?) = - ERROR.logIfEnabled(marker, msg, t, appender.value::error) + ERROR.logIfEnabled(marker, msg, t, appender::error) private fun KotlinLoggingLevel.logIfEnabled(msg: () -> Any?, logFunction: (Any?) -> Unit) { if (isLoggingEnabled()) { - logFunction(formatter.value.formatMessage(this, loggerName, msg)) + logFunction(formatter.formatMessage(this, loggerName, msg)) } } private fun KotlinLoggingLevel.logIfEnabled(msg: () -> Any?, t: Throwable?, logFunction: (Any?) -> Unit) { if (isLoggingEnabled()) { - logFunction(formatter.value.formatMessage(this, loggerName, t, msg)) + logFunction(formatter.formatMessage(this, loggerName, t, msg)) } } private fun KotlinLoggingLevel.logIfEnabled(marker: Marker?, msg: () -> Any?, logFunction: (Any?) -> Unit) { if (isLoggingEnabled()) { - logFunction(formatter.value.formatMessage(this, loggerName, marker, msg)) + logFunction(formatter.formatMessage(this, loggerName, marker, msg)) } } @@ -86,29 +86,29 @@ internal class KLoggerLinux( logFunction: (Any?) -> Unit ) { if (isLoggingEnabled()) { - logFunction(formatter.value.formatMessage(this, loggerName, marker, t, msg)) + logFunction(formatter.formatMessage(this, loggerName, marker, t, msg)) } } override fun entry(vararg argArray: Any?) { - TRACE.logIfEnabled({ "entry($argArray)" }, appender.value::trace) + TRACE.logIfEnabled({ "entry($argArray)" }, appender::trace) } override fun exit() { - TRACE.logIfEnabled({ "exit()" }, appender.value::trace) + TRACE.logIfEnabled({ "exit()" }, appender::trace) } override fun exit(result: T): T { - TRACE.logIfEnabled({ "exit($result)" }, appender.value::trace) + TRACE.logIfEnabled({ "exit($result)" }, appender::trace) return result } override fun throwing(throwable: T): T { - ERROR.logIfEnabled({ "throwing($throwable" }, throwable, appender.value::error) + ERROR.logIfEnabled({ "throwing($throwable" }, throwable, appender::error) return throwable } override fun catching(throwable: T) { - ERROR.logIfEnabled({ "catching($throwable" }, throwable, appender.value::error) + ERROR.logIfEnabled({ "catching($throwable" }, throwable, appender::error) } } From 0945c9563203598aa8c46e0625225cbe1e7b7c5d Mon Sep 17 00:00:00 2001 From: Nick Apperley Date: Tue, 14 Jul 2020 10:30:46 +1200 Subject: [PATCH 10/10] Removed GitHub Packages configuration from build file. --- build.gradle.kts | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8862b5ff..4845d742 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ import org.jetbrains.dokka.gradle.DokkaTask -import java.util.Date -import java.util.Properties +import java.util.* plugins { kotlin("multiplatform") version "1.3.72" @@ -112,17 +111,6 @@ kotlin { } publishing { - repositories { - maven { - val settings = fetchGitHubPackagesSettings() - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/${settings.owner}/${settings.repository}") - credentials { - username = settings.user - password = settings.token - } - } - } publications.withType { pom { name.set("kotlin-logging") @@ -183,26 +171,3 @@ bintray { } } } - -data class GitHubPackagesSettings(val user: String, val token: String, val owner: String, val repository: String) - -fun fetchGitHubPackagesSettings(): GitHubPackagesSettings { - var owner = "" - var repository = "" - var user = "" - var token = "" - val properties = Properties() - val filename = "github_packages.properties" - if (file(filename).exists()) { - file(filename).bufferedReader().use { br -> - with(properties) { - load(br) - owner = getProperty("gpr.owner") - repository = getProperty("gpr.repository") - user = getProperty("gpr.user") - token = getProperty("gpr.token") - } - } - } - return GitHubPackagesSettings(user = user, token = token, owner = owner, repository = repository) -}