From 4230a6e84c560c8b51eeb988ed3bfd1316a5e66d Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 11 Jun 2022 09:36:25 +0100 Subject: [PATCH] Remove MiraiLogger.subLogger in mirai-core-api to overcome declaration clash on native --- .../internal/utils/MarkedMiraiLogger.kt | 24 +++++++++---------- .../kotlin/logging/Log4j2LoggingTest.kt | 15 ++++++------ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/mirai-core-api/src/commonMain/kotlin/internal/utils/MarkedMiraiLogger.kt b/mirai-core-api/src/commonMain/kotlin/internal/utils/MarkedMiraiLogger.kt index 431b8b205..04ec4a426 100644 --- a/mirai-core-api/src/commonMain/kotlin/internal/utils/MarkedMiraiLogger.kt +++ b/mirai-core-api/src/commonMain/kotlin/internal/utils/MarkedMiraiLogger.kt @@ -10,8 +10,6 @@ package net.mamoe.mirai.internal.utils import net.mamoe.mirai.utils.MiraiLogger -import kotlin.jvm.JvmName -import kotlin.native.CName /** * 内部添加 [Marker] 支持, 并兼容旧 [MiraiLogger] API. @@ -39,16 +37,18 @@ internal fun Marker(name: String, vararg parents: Marker?): Marker { internal val MiraiLogger.markerOrNull get() = (this as? MarkedMiraiLogger)?.marker -/** - * Create a marked logger whose marker is a child of this' marker. - * - * Calling [MarkedMiraiLogger.subLogger] if possible, and creating [MiraiLoggerMarkedWrapper] otherwise. - */ -@JvmName("subLoggerImpl2") -@CName("", "subLogger2") -internal fun MiraiLogger.subLogger(name: String): MiraiLogger { - return subLoggerImpl(this, name) -} +// This clashes with the same declaration in mirai-core (same package), for native. +// +///** +// * Create a marked logger whose marker is a child of this' marker. +// * +// * Calling [MarkedMiraiLogger.subLogger] if possible, and creating [MiraiLoggerMarkedWrapper] otherwise. +// */ +//@JvmName("subLoggerImpl2") +//@CName("", "subLogger2") +//internal fun MiraiLogger.subLogger(name: String): MiraiLogger { +// return subLoggerImpl(this, name) +//} // used by mirai-core internal fun subLoggerImpl(origin: MiraiLogger, name: String): MiraiLogger { diff --git a/mirai-core-api/src/jvmBaseTest/kotlin/logging/Log4j2LoggingTest.kt b/mirai-core-api/src/jvmBaseTest/kotlin/logging/Log4j2LoggingTest.kt index 9d9311eef..31de6f9cc 100644 --- a/mirai-core-api/src/jvmBaseTest/kotlin/logging/Log4j2LoggingTest.kt +++ b/mirai-core-api/src/jvmBaseTest/kotlin/logging/Log4j2LoggingTest.kt @@ -16,12 +16,7 @@ import net.mamoe.mirai.utils.LoggerAdapters.asMiraiLogger import net.mamoe.mirai.utils.MiraiLogger import org.apache.logging.log4j.LogManager import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeEach -import kotlin.test.BeforeTest -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertIs -import kotlin.test.assertSame +import kotlin.test.* internal class Log4j2LoggingTest { @BeforeTest @@ -56,7 +51,7 @@ internal class Log4j2LoggingTest { val parent = MiraiLogger.Factory.create(Log4j2LoggingTest::class, "test1") val parentMarker = parent.cast().marker!! - val child = parent.subLogger("sub") + val child = subLoggerImpl(parent, "sub") val childMarker = child.markerOrNull!! assertEquals("test1", parentMarker.name) @@ -89,4 +84,8 @@ internal class Log4j2LoggingTest { info("InfoFF") } } -} \ No newline at end of file +} + +internal fun MiraiLogger.subLogger(s: String): MiraiLogger { + return subLoggerImpl(this, s) +}