aboutsummaryrefslogtreecommitdiff
path: root/runners/cli
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-06-22 15:17:55 +0200
committerGitHub <noreply@github.com>2021-06-22 15:17:55 +0200
commit9e15f07aefe6ea1f366466c6721b92e77e3f1b41 (patch)
tree60ab664edbab02f3c128c1158a9490d06d44f66e /runners/cli
parent8d6536d3a3d0dcd80a2e6b77b047524e15533f0b (diff)
downloaddokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.tar.gz
dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.tar.bz2
dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.zip
Logging in CLI (#1976)
Diffstat (limited to 'runners/cli')
-rw-r--r--runners/cli/api/cli.api2
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt26
2 files changed, 26 insertions, 2 deletions
diff --git a/runners/cli/api/cli.api b/runners/cli/api/cli.api
index f2f1fe44..b7ea94ff 100644
--- a/runners/cli/api/cli.api
+++ b/runners/cli/api/cli.api
@@ -64,6 +64,8 @@ public final class org/jetbrains/dokka/GlobalArguments : org/jetbrains/dokka/Dok
public final fun getHelpSourceSet ()Ljava/lang/Object;
public fun getIncludes ()Ljava/util/Set;
public final fun getJson ()Ljava/lang/String;
+ public final fun getLogger ()Lorg/jetbrains/dokka/utilities/DokkaLogger;
+ public final fun getLoggingLevel ()Lorg/jetbrains/dokka/utilities/LoggingLevel;
public fun getModuleName ()Ljava/lang/String;
public fun getModuleVersion ()Ljava/lang/String;
public fun getModules ()Ljava/util/List;
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index 36edb2d9..7a7a5582 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -3,6 +3,8 @@ package org.jetbrains.dokka
import kotlinx.cli.*
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
import org.jetbrains.dokka.utilities.DokkaConsoleLogger
+import org.jetbrains.dokka.utilities.DokkaLogger
+import org.jetbrains.dokka.utilities.LoggingLevel
import org.jetbrains.dokka.utilities.cast
import java.io.*
import java.net.MalformedURLException
@@ -108,8 +110,28 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
description = "Prints help for single -sourceSet"
)
+ val loggingLevel by parser.option(
+ ArgType.Choice(toVariant = {
+ when (it.toUpperCase().trim()) {
+ "DEBUG", "" -> LoggingLevel.DEBUG
+ "PROGRESS" -> LoggingLevel.PROGRESS
+ "INFO" -> LoggingLevel.INFO
+ "WARN" -> LoggingLevel.WARN
+ "ERROR" -> LoggingLevel.ERROR
+ else -> {
+ println("""Failed to deserialize logging level, got $it expected one of "DEBUG", "PROGRESS", "INFO", "WARN", "ERROR", falling back to DEBUG""")
+ LoggingLevel.DEBUG
+ }
+ }
+ }, toString = { it.toString() }
+ )).default(LoggingLevel.DEBUG)
+
override val modules: List<DokkaConfiguration.DokkaModuleDescription> = emptyList()
+ val logger: DokkaLogger by lazy {
+ DokkaConsoleLogger(loggingLevel)
+ }
+
init {
parser.parse(args)
@@ -129,7 +151,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
.add(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it))
}
else {
- DokkaConsoleLogger.warn("Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.")
+ logger.warn("Invalid -srcLink syntax. Expected: <path>=<url>[#lineSuffix]. No source links will be generated.")
}
}
@@ -378,6 +400,6 @@ fun main(args: Array<String>) {
)
else
globalArguments
- DokkaGenerator(configuration, DokkaConsoleLogger).generate()
+ DokkaGenerator(configuration, globalArguments.logger).generate()
}