diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-15 16:38:25 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-15 17:56:04 +0200 |
commit | e32e42e084d4e150387a7e9ec4ee00ae3974babd (patch) | |
tree | 0fd84a7e6c6580e36ca7362ef432a79ed94e1366 | |
parent | ddccb8d23057d4eb14d5e3e35152e1f4aa00a77d (diff) | |
download | dokka-e32e42e084d4e150387a7e9ec4ee00ae3974babd.tar.gz dokka-e32e42e084d4e150387a7e9ec4ee00ae3974babd.tar.bz2 dokka-e32e42e084d4e150387a7e9ec4ee00ae3974babd.zip |
Use DokkaLogger instead of println and adjust log levels for less verbosity by default
11 files changed, 28 insertions, 58 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 936fbe6c..fabbc889 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -66,19 +66,6 @@ class DokkaBootstrapImpl : DokkaBootstrap { override fun error(message: String) { consumer.accept("error", message).also { errorsCount++ } } - - override fun report() { - if (warningsCount > 0 || errorsCount > 0) { - println( - "Generation completed with $warningsCount warning" + - (if (warningsCount == 1) "" else "s") + - " and $errorsCount error" + - if (errorsCount == 1) "" else "s" - ) - } else { - println("generation completed successfully") - } - } } private lateinit var generator: DokkaGenerator diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index d694cc8c..4262d890 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -6,6 +6,7 @@ import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.dokka.utilities.report /** @@ -17,7 +18,7 @@ class DokkaGenerator( private val configuration: DokkaConfiguration, private val logger: DokkaLogger ) { - fun generate() = timed { + fun generate() = timed(logger) { report("Initializing plugins") val context = initializePlugins(configuration, logger) @@ -115,7 +116,7 @@ class DokkaGenerator( fun reportAfterRendering(context: DokkaContext) { context.unusedPoints.takeIf { it.isNotEmpty() }?.also { - logger.warn("Unused extension points found: ${it.joinToString(", ")}") + logger.info("Unused extension points found: ${it.joinToString(", ")}") } logger.report() @@ -142,12 +143,12 @@ private class Timer(startTime: Long, private val logger: DokkaLogger?) { } fun dump(prefix: String = "") { - println(prefix) + logger?.info(prefix) val namePad = steps.map { it.first.length }.max() ?: 0 val timePad = steps.windowed(2).map { (p1, p2) -> p2.second - p1.second }.max()?.toString()?.length ?: 0 steps.windowed(2).forEach { (p1, p2) -> if (p1.first.isNotBlank()) { - println("${p1.first.padStart(namePad)}: ${(p2.second - p1.second).toString().padStart(timePad)}") + logger?.info("${p1.first.padStart(namePad)}: ${(p2.second - p1.second).toString().padStart(timePad)}") } } } diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index 61ae1918..323039e9 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -205,9 +205,9 @@ private class DokkaContextConfigurationImpl( "\t${it.key} by " + (it.value.singleOrNull() ?: it.value) } - logger.progress("Loaded plugins: $pluginNames") - logger.progress("Loaded: $loadedListForDebug") - logger.progress("Suppressed: $suppressedList") + logger.info("Loaded plugins: $pluginNames") + logger.info("Loaded: $loadedListForDebug") + logger.info("Suppressed: $suppressedList") } } @@ -220,4 +220,4 @@ private fun checkClasspath(classLoader: URLClassLoader) { } } -private fun <K, V> MutableMap<K, MutableList<V>>.listFor(key: K) = getOrPut(key, ::mutableListOf)
\ No newline at end of file +private fun <K, V> MutableMap<K, MutableList<V>>.listFor(key: K) = getOrPut(key, ::mutableListOf) diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt index 4b671f7b..6b8ed5d2 100644 --- a/core/src/main/kotlin/utilities/DokkaLogging.kt +++ b/core/src/main/kotlin/utilities/DokkaLogging.kt @@ -8,7 +8,18 @@ interface DokkaLogger { fun progress(message: String) fun warn(message: String) fun error(message: String) - fun report() +} + +fun DokkaLogger.report() { + if (DokkaConsoleLogger.warningsCount > 0 || DokkaConsoleLogger.errorsCount > 0) { + info("Generation completed with ${DokkaConsoleLogger.warningsCount} warning" + + (if(DokkaConsoleLogger.warningsCount == 1) "" else "s") + + " and ${DokkaConsoleLogger.errorsCount} error" + + if(DokkaConsoleLogger.errorsCount == 1) "" else "s" + ) + } else { + info("generation completed successfully") + } } object DokkaConsoleLogger : DokkaLogger { @@ -24,16 +35,4 @@ object DokkaConsoleLogger : DokkaLogger { override fun warn(message: String) = println("WARN: $message").also { warningsCount++ } override fun error(message: String) = println("ERROR: $message").also { errorsCount++ } - - override fun report() { - if (warningsCount > 0 || errorsCount > 0) { - println("Generation completed with $warningsCount warning" + - (if(warningsCount == 1) "" else "s") + - " and $errorsCount error" + - if(errorsCount == 1) "" else "s" - ) - } else { - println("generation completed successfully") - } - } } diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt index 19235597..30c3d07f 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt @@ -51,7 +51,7 @@ class Android0GradleIntegrationTest(override val versions: BuildVersions) : Abst @Test fun execute() { - val result = createGradleRunner("dokkaHtml", "--stacktrace").buildRelaxed() + val result = createGradleRunner("dokkaHtml", "-i", "-s").buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome) val htmlOutputDir = File(projectDir, "build/dokka/html") diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt index c9c45d58..929c99aa 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt @@ -29,7 +29,7 @@ class BasicGradleIntegrationTest(override val versions: BuildVersions) : Abstrac @Test fun execute() { - val result = createGradleRunner("dokkaHtml", "dokkaJavadoc", "dokkaGfm", "dokkaJekyll", "--stacktrace") + val result = createGradleRunner("dokkaHtml", "dokkaJavadoc", "dokkaGfm", "dokkaJekyll", "-i", "-s") .buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome) diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGroovyIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGroovyIntegrationTest.kt index b20a7b2d..0d812ca9 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGroovyIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGroovyIntegrationTest.kt @@ -33,7 +33,7 @@ class BasicGroovyIntegrationTest(override val versions: BuildVersions) : Abstrac @Test fun execute() { - val result = createGradleRunner("dokkaHtml", "dokkaJavadoc", "dokkaGfm", "dokkaJekyll", "--stacktrace") + val result = createGradleRunner("dokkaHtml", "dokkaJavadoc", "dokkaGfm", "dokkaJekyll", "-i", "-s") .buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome) diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt index 50ae22f9..64cf3d75 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multimodule0IntegrationTest.kt @@ -26,7 +26,7 @@ class Multimodule0IntegrationTest(override val versions: BuildVersions) : Abstra @Test fun execute() { - val result = createGradleRunner(":moduleA:dokkaHtmlMultimodule", "--stacktrace").buildRelaxed() + val result = createGradleRunner(":moduleA:dokkaHtmlMultimodule", "-i","-s").buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":moduleA:dokkaHtmlMultimodule")).outcome) diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt index 3e254dd0..d6d2ff6a 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Multiplatform0GradleIntegrationTest.kt @@ -27,7 +27,7 @@ class Multiplatform0GradleIntegrationTest(override val versions: BuildVersions) @Test fun execute() { - val result = createGradleRunner("dokkaHtml", "--stacktrace").buildRelaxed() + val result = createGradleRunner("dokkaHtml", "-i", "-s").buildRelaxed() assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome) diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt index 403fc773..4b5f4fa9 100644 --- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt +++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt @@ -12,16 +12,4 @@ class MavenDokkaLogger(val log: Log) : DokkaLogger { override fun progress(message: String) = log.info(message) override fun warn(message: String) = log.warn(message).also { warningsCount++ } override fun error(message: String) = log.error(message).also { errorsCount++ } - - override fun report() { - if (warningsCount > 0 || errorsCount > 0) { - log.info("Generation completed with $warningsCount warning" + - (if(warningsCount == 1) "" else "s") + - " and $errorsCount error" + - if(errorsCount == 1) "" else "s" - ) - } else { - log.info("generation completed successfully") - } - } -}
\ No newline at end of file +} diff --git a/testApi/src/main/kotlin/testApi/logger/TestLogger.kt b/testApi/src/main/kotlin/testApi/logger/TestLogger.kt index 8f88f88b..1dbe4a48 100644 --- a/testApi/src/main/kotlin/testApi/logger/TestLogger.kt +++ b/testApi/src/main/kotlin/testApi/logger/TestLogger.kt @@ -45,9 +45,4 @@ class TestLogger(private val logger: DokkaLogger) : DokkaLogger { _errorMessages.add(message) logger.error(message) } - - override fun report() { - logger.report() - } - -}
\ No newline at end of file +} |