Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Dokka for javadocs #82 #99

Merged
merged 1 commit into from
Nov 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import java.util.*
import org.jetbrains.dokka.gradle.DokkaTask
import java.util.Date

plugins {
kotlin("multiplatform") version "1.3.50"
id("com.jfrog.bintray") version "1.8.4"
id("org.jetbrains.dokka") version "0.10.0"
`maven-publish`
`java-library` //todo: ask whether we need javadoc at all as it is always empty
}
Expand All @@ -16,15 +18,23 @@ version = "1.6.27"

repositories {
mavenCentral()
jcenter()
}



tasks {
register<Jar>("javadocJar") {
val javadocTask = getByName<Javadoc>("javadoc")
from(javadocTask.destinationDir)
dependsOn(javadocTask)
val dokkaTask = getByName<DokkaTask>("dokka")
from(dokkaTask.outputDirectory)
dependsOn(dokkaTask)
archiveClassifier.set("javadoc")
}
dokka {
outputFormat = "javadoc"
outputDirectory = "$buildDir/dokka"

}
}

kotlin {
Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/kotlin/mu/KotlinLogging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ package mu
expect object KotlinLogging {
/**
* This method allow defining the logger in a file in the following way:
* ```
* val logger = KotlinLogging.logger {}
* ```
*/
fun logger(func: () -> Unit): KLogger

Expand Down
2 changes: 2 additions & 0 deletions src/jsMain/kotlin/mu/KotlinLogging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import mu.internal.KLoggerJS
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 = KLoggerJS(func::class.js.name)

Expand Down
2 changes: 2 additions & 0 deletions src/jvmMain/kotlin/mu/KLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import org.slf4j.Logger
/**
* An extension for [Logger] with Lazy message evaluation
* example:
* ```
* logger.info{"this is $lazy evaluated string"}
*```
*/
actual interface KLogger : Logger {

Expand Down
2 changes: 2 additions & 0 deletions src/jvmMain/kotlin/mu/KLogging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import mu.internal.KLoggerFactory
/**
* A class with logging capabilities
* usage example:
* ```
* class ClassWithLogging {
* companion object: KLogging()
* fun test() {
* logger.info{"test ClassWithLogging"}
* }
* }
* ```
*/
open class KLogging : KLoggable {
override val logger: KLogger = logger()
Expand Down
2 changes: 2 additions & 0 deletions src/jvmMain/kotlin/mu/KotlinLogging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.slf4j.Logger
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 = KLoggerFactory.logger(func)

Expand Down
18 changes: 12 additions & 6 deletions src/jvmMain/kotlin/mu/KotlinLoggingMDC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ import org.slf4j.MDC

/**
* Use a pair in MDC context. Example:
* `withLoggingContext("userId" to userId) {
* ```
* withLoggingContext("userId" to userId) {
* doSomething()
* }`
* }
* ```
*/
inline fun <T> withLoggingContext(pair: Pair<String, String>, body: () -> T): T =
MDC.putCloseable(pair.first, pair.second).use { body() }

/**
* Use a vary number of pairs in MDC context. Example:
* `withLoggingContext("userId" to userId) {
* ```
* withLoggingContext("userId" to userId) {
* doSomething()
* }`
* }
* ```
*/
inline fun <T> withLoggingContext(vararg pair: Pair<String, String>, body: () -> T): T {
try {
Expand All @@ -28,9 +32,11 @@ inline fun <T> withLoggingContext(vararg pair: Pair<String, String>, body: () ->

/**
* Use a map in MDC context. Example:
* `withLoggingContext(mapOf("userId" to userId)) {
* ```
* withLoggingContext(mapOf("userId" to userId)) {
* doSomething()
* }`
* }
* ```
*/
inline fun <T> withLoggingContext(map: Map<String, String>, body: () -> T): T {
try {
Expand Down