aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-15 16:38:25 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-15 17:56:04 +0200
commite32e42e084d4e150387a7e9ec4ee00ae3974babd (patch)
tree0fd84a7e6c6580e36ca7362ef432a79ed94e1366 /core
parentddccb8d23057d4eb14d5e3e35152e1f4aa00a77d (diff)
downloaddokka-e32e42e084d4e150387a7e9ec4ee00ae3974babd.tar.gz
dokka-e32e42e084d4e150387a7e9ec4ee00ae3974babd.tar.bz2
dokka-e32e42e084d4e150387a7e9ec4ee00ae3974babd.zip
Use DokkaLogger instead of println and adjust log levels for less verbosity by default
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt13
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt9
-rw-r--r--core/src/main/kotlin/plugability/DokkaContext.kt8
-rw-r--r--core/src/main/kotlin/utilities/DokkaLogging.kt25
4 files changed, 21 insertions, 34 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")
- }
- }
}