Remove MiraiLogger.subLogger in mirai-core-api to overcome declaration clash on native

This commit is contained in:
Him188 2022-06-11 09:36:25 +01:00
parent fe0a4de368
commit 4230a6e84c
2 changed files with 19 additions and 20 deletions

View File

@ -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 {

View File

@ -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")
}
}
}
}
internal fun MiraiLogger.subLogger(s: String): MiraiLogger {
return subLoggerImpl(this, s)
}