diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-06-22 15:17:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 15:17:55 +0200 |
commit | 9e15f07aefe6ea1f366466c6721b92e77e3f1b41 (patch) | |
tree | 60ab664edbab02f3c128c1158a9490d06d44f66e /plugins | |
parent | 8d6536d3a3d0dcd80a2e6b77b047524e15533f0b (diff) | |
download | dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.tar.gz dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.tar.bz2 dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.zip |
Logging in CLI (#1976)
Diffstat (limited to 'plugins')
10 files changed, 57 insertions, 12 deletions
diff --git a/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt b/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt index 9213c90b..adb61e7e 100644 --- a/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt +++ b/plugins/all-modules-page/src/test/kotlin/MultiModuleDokkaTestGenerator.kt @@ -85,7 +85,7 @@ class MultiModuleTestBuilder : TestBuilder<MultiModuleTestMethods>() { ) } -abstract class MultiModuleAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger)) : +abstract class MultiModuleAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger())) : AbstractTest<MultiModuleTestMethods, MultiModuleTestBuilder, MultiModuleDokkaTestGenerator>( ::MultiModuleTestBuilder, ::MultiModuleDokkaTestGenerator, diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt index 09ea6083..67ba2dd3 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt @@ -14,8 +14,8 @@ import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentCon fun testPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit): RawTestPage { val content = PageContentBuilder( EmptyCommentConverter, - KotlinSignatureProvider(EmptyCommentConverter, DokkaConsoleLogger), - DokkaConsoleLogger + KotlinSignatureProvider(EmptyCommentConverter, DokkaConsoleLogger()), + DokkaConsoleLogger() ).contentFor( DRI.topLevel, emptySet(), diff --git a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt index 792754fb..25f6656e 100644 --- a/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt +++ b/plugins/base/base-test-utils/src/main/kotlin/testRunner/baseTestApi.kt @@ -12,6 +12,7 @@ import org.jetbrains.dokka.testApi.logger.TestLogger import org.jetbrains.dokka.testApi.testRunner.* import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.dokka.utilities.LoggingLevel class BaseDokkaTestGenerator( configuration: DokkaConfiguration, @@ -101,7 +102,7 @@ class BaseTestBuilder : TestBuilder<BaseTestMethods>() { ) } -abstract class BaseAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger)) : AbstractTest<BaseTestMethods, BaseTestBuilder, BaseDokkaTestGenerator>( +abstract class BaseAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger(LoggingLevel.DEBUG))) : AbstractTest<BaseTestMethods, BaseTestBuilder, BaseDokkaTestGenerator>( ::BaseTestBuilder, ::BaseDokkaTestGenerator, logger, diff --git a/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt b/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt index 2a927b97..982d6550 100644 --- a/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt +++ b/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt @@ -116,7 +116,7 @@ class FailOnWarningTest : BaseAbstractTest() { } private class ZeroErrorOrWarningCountDokkaLogger( - logger: DokkaLogger = DokkaConsoleLogger + logger: DokkaLogger = DokkaConsoleLogger() ) : DokkaLogger by logger { override var warningsCount: Int = 0 override var errorsCount: Int = 0 diff --git a/plugins/base/src/test/kotlin/basic/LoggerTest.kt b/plugins/base/src/test/kotlin/basic/LoggerTest.kt new file mode 100644 index 00000000..92ffb539 --- /dev/null +++ b/plugins/base/src/test/kotlin/basic/LoggerTest.kt @@ -0,0 +1,44 @@ +package basic + +import org.jetbrains.dokka.utilities.DokkaConsoleLogger +import org.jetbrains.dokka.utilities.LoggingLevel +import org.jetbrains.dokka.utilities.MessageEmitter +import org.junit.jupiter.api.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class LoggerTest { + class AccumulatingEmitter : MessageEmitter { + val messages: MutableList<String> = mutableListOf() + override fun invoke(message: String) { + messages.add(message) + } + } + + @Test + fun `should display info messages if logging is info`(){ + val emitter = AccumulatingEmitter() + val logger = DokkaConsoleLogger(LoggingLevel.INFO, emitter) + + logger.debug("Debug!") + logger.info("Info!") + + assertTrue(emitter.messages.size > 0) + assertTrue(emitter.messages.any { it == "Info!" }) + assertFalse(emitter.messages.any { it == "Debug!" }) + } + + @Test + fun `should not display info messages if logging is warn`(){ + val emitter = AccumulatingEmitter() + val logger = DokkaConsoleLogger(LoggingLevel.WARN, emitter) + + logger.warn("Warning!") + logger.info("Info!") + + + assertTrue(emitter.messages.size > 0) + assertFalse(emitter.messages.any { it.contains("Info!") }) + assertTrue(emitter.messages.any { it.contains("Warning!") }) + } +}
\ No newline at end of file diff --git a/plugins/base/src/test/kotlin/signatures/ObviousTypeSkippingTest.kt b/plugins/base/src/test/kotlin/signatures/ObviousTypeSkippingTest.kt index e85aa5a1..839fb7fe 100644 --- a/plugins/base/src/test/kotlin/signatures/ObviousTypeSkippingTest.kt +++ b/plugins/base/src/test/kotlin/signatures/ObviousTypeSkippingTest.kt @@ -4,16 +4,16 @@ import matchers.content.assertNode import matchers.content.hasExactText import org.jetbrains.dokka.model.firstMemberOfType import org.jetbrains.dokka.pages.* -import org.jetbrains.dokka.testApi.logger.FilteringLogger import org.jetbrains.dokka.testApi.logger.TestLogger import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.utilities.DokkaConsoleLogger +import org.jetbrains.dokka.utilities.LoggingLevel import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.MethodSource import kotlin.reflect.KClass class ObviousTypeSkippingTest : BaseAbstractTest( - logger = TestLogger(FilteringLogger(minLevel = FilteringLogger.Level.Warn, DokkaConsoleLogger)) + logger = TestLogger(DokkaConsoleLogger(LoggingLevel.WARN)) ) { private fun source(signature: String) = diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt index 4b4116a2..4d296d17 100644 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt +++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt @@ -75,7 +75,7 @@ class ContextModuleAndPackageDocumentationReaderTest1 : AbstractContextModuleAnd private val context by lazy { DokkaContext.create( configuration = configurationBuilder.build(), - logger = TestLogger(DokkaConsoleLogger), + logger = TestLogger(DokkaConsoleLogger()), pluginOverrides = emptyList() ) } diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt index 9319f5af..d8ea90d7 100644 --- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt +++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt @@ -39,7 +39,7 @@ class ContextModuleAndPackageDocumentationReaderTest3 : AbstractContextModuleAnd private val context by lazy { DokkaContext.create( configuration = configurationBuilder.build(), - logger = DokkaConsoleLogger, + logger = DokkaConsoleLogger(), pluginOverrides = emptyList() ) } diff --git a/plugins/base/src/test/kotlin/transformers/InvalidContentModuleAndPackageDocumentationReaderTest.kt b/plugins/base/src/test/kotlin/transformers/InvalidContentModuleAndPackageDocumentationReaderTest.kt index b9837750..6a1f5f11 100644 --- a/plugins/base/src/test/kotlin/transformers/InvalidContentModuleAndPackageDocumentationReaderTest.kt +++ b/plugins/base/src/test/kotlin/transformers/InvalidContentModuleAndPackageDocumentationReaderTest.kt @@ -52,14 +52,14 @@ class InvalidContentModuleAndPackageDocumentationReaderTest : AbstractContextMod private val contextA by lazy { DokkaContext.create( configuration = configurationBuilderA.build(), - logger = DokkaConsoleLogger, + logger = DokkaConsoleLogger(), pluginOverrides = emptyList() ) } private val contextB by lazy { DokkaContext.create( configuration = configurationBuilderB.build(), - logger = DokkaConsoleLogger, + logger = DokkaConsoleLogger(), pluginOverrides = emptyList() ) } diff --git a/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt b/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt index 04420662..50a68efb 100644 --- a/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt +++ b/plugins/templating/src/test/kotlin/templates/TemplatingDokkaTestGenerator.kt @@ -61,7 +61,7 @@ class TemplatingTestBuilder : TestBuilder<TemplatingTestMethods>() { ) } -abstract class TemplatingAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger)) : +abstract class TemplatingAbstractTest(logger: TestLogger = TestLogger(DokkaConsoleLogger())) : AbstractTest<TemplatingTestMethods, TemplatingTestBuilder, TemplatingDokkaTestGenerator>( ::TemplatingTestBuilder, ::TemplatingDokkaTestGenerator, |