mirror of
https://github.com/mamoe/mirai.git
synced 2026-09-04 22:22:54 +08:00
Add SynchronizedStdoutLogger for tests
This commit is contained in:
@@ -20,11 +20,6 @@ internal actual fun initPlatform() {
|
||||
}
|
||||
|
||||
private val init: Unit by lazy {
|
||||
MiraiLogger.setDefaultLoggerCreator {
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
net.mamoe.mirai.internal.utils.StdoutLogger(it)
|
||||
}
|
||||
|
||||
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) != null) {
|
||||
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.network.framework
|
||||
|
||||
import kotlinx.atomicfu.locks.withLock
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
|
||||
private val lock = ReentrantLock()
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "CANNOT_OVERRIDE_INVISIBLE_MEMBER")
|
||||
internal class SynchronizedStdoutLogger(override val identity: String?) : net.mamoe.mirai.internal.utils.StdoutLogger(
|
||||
identity) {
|
||||
|
||||
override val output: (String) -> Unit = { str ->
|
||||
lock.withLock { println(str) }
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
package net.mamoe.mirai.internal.test
|
||||
|
||||
import net.mamoe.mirai.IMirai
|
||||
import net.mamoe.mirai.internal.network.framework.SynchronizedStdoutLogger
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.Timeout
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -24,6 +26,10 @@ abstract class AbstractTest {
|
||||
init {
|
||||
initPlatform()
|
||||
|
||||
MiraiLogger.setDefaultLoggerCreator {
|
||||
SynchronizedStdoutLogger(it)
|
||||
}
|
||||
|
||||
System.setProperty("mirai.debug.network.packet.logger", "true")
|
||||
System.setProperty("mirai.debug.network.state.observer.logging", "true")
|
||||
System.setProperty("mirai.debug.network.show.all.components", "true")
|
||||
|
||||
Reference in New Issue
Block a user