aboutsummaryrefslogtreecommitdiff
path: root/core/test-api
diff options
context:
space:
mode:
Diffstat (limited to 'core/test-api')
-rw-r--r--core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt b/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt
index 0bc66a2b..e70200a7 100644
--- a/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt
+++ b/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt
@@ -1,24 +1,28 @@
package org.jetbrains.dokka.testApi.logger
import org.jetbrains.dokka.utilities.DokkaLogger
+import java.util.Collections
+/*
+ * Even in tests it be used in a concurrent environment, so needs to be thread safe
+ */
class TestLogger(private val logger: DokkaLogger) : DokkaLogger {
override var warningsCount: Int by logger::warningsCount
override var errorsCount: Int by logger::errorsCount
- private var _debugMessages = mutableListOf<String>()
+ private var _debugMessages = synchronizedMutableListOf<String>()
val debugMessages: List<String> get() = _debugMessages.toList()
- private var _infoMessages = mutableListOf<String>()
+ private var _infoMessages = synchronizedMutableListOf<String>()
val infoMessages: List<String> get() = _infoMessages.toList()
- private var _progressMessages = mutableListOf<String>()
+ private var _progressMessages = synchronizedMutableListOf<String>()
val progressMessages: List<String> get() = _progressMessages.toList()
- private var _warnMessages = mutableListOf<String>()
+ private var _warnMessages = synchronizedMutableListOf<String>()
val warnMessages: List<String> get() = _warnMessages.toList()
- private var _errorMessages = mutableListOf<String>()
+ private var _errorMessages = synchronizedMutableListOf<String>()
val errorMessages: List<String> get() = _errorMessages.toList()
override fun debug(message: String) {
@@ -45,4 +49,6 @@ class TestLogger(private val logger: DokkaLogger) : DokkaLogger {
_errorMessages.add(message)
logger.error(message)
}
+
+ private fun <T> synchronizedMutableListOf(): MutableList<T> = Collections.synchronizedList(mutableListOf())
}