mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
AbstractLoggerController
This commit is contained in:
parent
f1113bbcce
commit
ada3c8f375
@ -2,10 +2,9 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.internal.data.builtins
|
||||
|
@ -2,39 +2,27 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.internal.logging
|
||||
|
||||
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
|
||||
import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig
|
||||
import net.mamoe.mirai.console.logging.AbstractLoggerController
|
||||
import net.mamoe.mirai.console.logging.LogPriority
|
||||
import net.mamoe.mirai.console.logging.LoggerController
|
||||
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
|
||||
@ConsoleFrontEndImplementation
|
||||
@ConsoleInternalApi
|
||||
internal object LoggerControllerImpl : LoggerController {
|
||||
internal object LoggerControllerImpl : AbstractLoggerController() {
|
||||
|
||||
private fun shouldLog(
|
||||
priority: LogPriority,
|
||||
settings: LogPriority
|
||||
): Boolean = settings <= priority
|
||||
|
||||
private fun shouldLog(identity: String?, priority: LogPriority): Boolean {
|
||||
return if (identity == null) {
|
||||
shouldLog(priority, LoggerConfig.defaultPriority)
|
||||
} else {
|
||||
shouldLog(priority, LoggerConfig.loggers[identity] ?: LoggerConfig.defaultPriority)
|
||||
}
|
||||
override fun getPriority(identity: String?): LogPriority = if (identity == null) {
|
||||
LoggerConfig.defaultPriority
|
||||
} else {
|
||||
LoggerConfig.loggers[identity] ?: LoggerConfig.defaultPriority
|
||||
}
|
||||
|
||||
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean =
|
||||
shouldLog(identity, LogPriority.by(priority))
|
||||
|
||||
}
|
@ -2,10 +2,9 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.internal.logging
|
||||
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.logging
|
||||
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
|
||||
public abstract class AbstractLoggerController : LoggerController {
|
||||
|
||||
protected open fun shouldLog(
|
||||
priority: LogPriority,
|
||||
settings: LogPriority
|
||||
): Boolean = settings <= priority
|
||||
|
||||
protected abstract fun getPriority(identity: String?): LogPriority
|
||||
|
||||
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean =
|
||||
shouldLog(LogPriority.by(priority), getPriority(identity))
|
||||
|
||||
}
|
@ -2,10 +2,9 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.logging
|
||||
@ -41,4 +40,4 @@ public enum class LogPriority {
|
||||
mapped = SimpleLogger.LogPriority.valueOf(name)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,9 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.logging
|
||||
|
Loading…
Reference in New Issue
Block a user