[core+console] Improve logging hierarchy: (#2196)

- always use factory API from mirai-core
- Terminal is still overriding standard outputs
- plugins are forbidden to override logging framework (this was allowed but not working before)
This commit is contained in:
Him188
2022-08-27 18:46:16 +08:00
committed by GitHub
parent 2d393ee0b0
commit f0651c81c6
23 changed files with 314 additions and 127 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 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.
@@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package net.mamoe.mirai.utils.logging
import io.ktor.client.*
@@ -20,18 +22,6 @@ import kotlin.test.assertFalse
import kotlin.test.assertIs
internal class MiraiLog4JAdapterTest {
@Suppress("DEPRECATION_ERROR")
@Test
fun `services prevail than legacy overrides`() {
MiraiLogger.setDefaultLoggerCreator {
net.mamoe.mirai.utils.SimpleLogger("my logger") { _: String?, _: Throwable? -> }
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
assertIs<net.mamoe.mirai.internal.utils.Log4jLoggerAdapter>(MiraiLogger.Factory.create(this::class))
}
@Test
fun `using log4j`() {
assertIs<MiraiLog4JFactory>(loadService(MiraiLogger.Factory::class))