aboutsummaryrefslogtreecommitdiff
path: root/runners/cli
diff options
context:
space:
mode:
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()
}