From e7c23a65606a5a844d1664552c935590a06bf58d Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Thu, 14 Nov 2019 16:13:30 +0100 Subject: Few fixes for logger --- core/src/main/kotlin/DokkaBootstrapImpl.kt | 8 ++++++++ core/src/main/kotlin/DokkaGenerator.kt | 4 ++-- core/src/main/kotlin/Utilities/DokkaLogging.kt | 12 ++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index b48b62d4..2e52d9c6 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -25,10 +25,18 @@ fun parsePerPackageOptions(arg: String): List { class DokkaBootstrapImpl : DokkaBootstrap { private class DokkaProxyLogger(val consumer: BiConsumer) : DokkaLogger { + override fun debug(message: String) { + consumer.accept("debug", message) + } + override fun info(message: String) { consumer.accept("info", message) } + override fun progress(message: String) { + consumer.accept("progress", message) + } + override fun warn(message: String) { consumer.accept("warn", message) } diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index a522ea40..fb4bf98f 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -24,10 +24,10 @@ class DokkaGenerator( ) { fun generate(): Unit { - logger.info("Initializing plugins") + logger.debug("Initializing plugins") val context = DokkaContext.from(configuration.pluginsClasspath) context.pluginNames.also { names -> - logger.info("Loaded plugins: $names") + logger.progress("Loaded plugins: $names") names.groupingBy { it }.eachCount().filter { it.value > 1 }.forEach { logger.warn("Duplicate plugin name: ${it.key}. It will make debugging much harder.") } diff --git a/core/src/main/kotlin/Utilities/DokkaLogging.kt b/core/src/main/kotlin/Utilities/DokkaLogging.kt index 1ef52837..d0d1bff6 100644 --- a/core/src/main/kotlin/Utilities/DokkaLogging.kt +++ b/core/src/main/kotlin/Utilities/DokkaLogging.kt @@ -1,7 +1,9 @@ package org.jetbrains.dokka interface DokkaLogger { + fun debug(message: String) fun info(message: String) + fun progress(message: String) fun warn(message: String) fun error(message: String) } @@ -9,11 +11,13 @@ interface DokkaLogger { object DokkaConsoleLogger : DokkaLogger { var warningCount: Int = 0 + override fun debug(message: String)= println(message) + + override fun progress(message: String) = println("PROGRESS: $message") + override fun info(message: String) = println(message) - override fun warn(message: String) { - println("WARN: $message") - warningCount++ - } + + override fun warn(message: String) = println("WARN: $message").also { warningCount++ } override fun error(message: String) = println("ERROR: $message") -- cgit