Skip to content

Commit

Permalink
use Dokka for javadocs oshai#82
Browse files Browse the repository at this point in the history
Signed-off-by: Piyush Mor <piyush.mor@zalando.de>
  • Loading branch information
Piyush Mor committed Nov 15, 2019
1 parent d6eac94 commit 713a129
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
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

0 comments on commit 713a129

Please sign in to comment.