diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-01-31 18:38:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-31 18:38:09 +0100 |
commit | fe360f7fadc7173be3ae170778a93ebd01962149 (patch) | |
tree | 25ea1be7e75ffd3c3235cd8ab4109bb26c5b2ad0 /core/src/main/kotlin/utilities/DokkaLogging.kt | |
parent | eb54d69a5cd8e27b1235a23b9098e285c408cb23 (diff) | |
download | dokka-fe360f7fadc7173be3ae170778a93ebd01962149.tar.gz dokka-fe360f7fadc7173be3ae170778a93ebd01962149.tar.bz2 dokka-fe360f7fadc7173be3ae170778a93ebd01962149.zip |
Make implementations of DokkaLogger thread-safe (#2827)
Diffstat (limited to 'core/src/main/kotlin/utilities/DokkaLogging.kt')
-rw-r--r-- | core/src/main/kotlin/utilities/DokkaLogging.kt | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt index 0302b8a2..80c762a3 100644 --- a/core/src/main/kotlin/utilities/DokkaLogging.kt +++ b/core/src/main/kotlin/utilities/DokkaLogging.kt @@ -1,5 +1,7 @@ package org.jetbrains.dokka.utilities +import java.util.concurrent.atomic.AtomicInteger + interface DokkaLogger { var warningsCount: Int var errorsCount: Int @@ -40,8 +42,16 @@ class DokkaConsoleLogger( val minLevel: LoggingLevel = LoggingLevel.DEBUG, private val emitter: MessageEmitter = MessageEmitter.consoleEmitter ) : DokkaLogger { - override var warningsCount: Int = 0 - override var errorsCount: Int = 0 + private val warningsCounter = AtomicInteger() + private val errorsCounter = AtomicInteger() + + override var warningsCount: Int + get() = warningsCounter.get() + set(value) = warningsCounter.set(value) + + override var errorsCount: Int + get() = errorsCounter.get() + set(value) = errorsCounter.set(value) override fun debug(message: String) { if (shouldBeDisplayed(LoggingLevel.DEBUG)) emitter(message) @@ -59,14 +69,14 @@ class DokkaConsoleLogger( if (shouldBeDisplayed(LoggingLevel.WARN)) { emitter("WARN: $message") } - warningsCount++ + warningsCounter.incrementAndGet() } override fun error(message: String) { if (shouldBeDisplayed(LoggingLevel.ERROR)) { emitter("ERROR: $message") } - errorsCount++ + errorsCounter.incrementAndGet() } private fun shouldBeDisplayed(messageLevel: LoggingLevel): Boolean = messageLevel.index >= minLevel.index |