mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Move LogPriority into AbstractLoggerController
This commit is contained in:
parent
d345157349
commit
3a5fa11554
@ -12,19 +12,19 @@ package net.mamoe.mirai.console.internal.data.builtins
|
||||
import net.mamoe.mirai.console.data.AutoSavePluginConfig
|
||||
import net.mamoe.mirai.console.data.ValueDescription
|
||||
import net.mamoe.mirai.console.data.value
|
||||
import net.mamoe.mirai.console.logging.LogPriority
|
||||
import net.mamoe.mirai.console.logging.AbstractLoggerController
|
||||
|
||||
internal object LoggerConfig : AutoSavePluginConfig("Logger") {
|
||||
@ValueDescription("""
|
||||
日志输出等级 可选值: ALL, VERBOSE, DEBUG, INFO, WARNING, ERROR, NONE
|
||||
""")
|
||||
val defaultPriority by value(LogPriority.INFO)
|
||||
val defaultPriority by value(AbstractLoggerController.LogPriority.INFO)
|
||||
|
||||
@ValueDescription("""
|
||||
特定日志记录器输出等级
|
||||
""")
|
||||
val loggers: Map<String, LogPriority> by value(
|
||||
mapOf("example.logger" to LogPriority.NONE)
|
||||
val loggers: Map<String, AbstractLoggerController.LogPriority> by value(
|
||||
mapOf("example.logger" to AbstractLoggerController.LogPriority.NONE)
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ 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.util.ConsoleInternalApi
|
||||
|
||||
@ConsoleFrontEndImplementation
|
||||
|
@ -11,6 +11,7 @@ package net.mamoe.mirai.console.logging
|
||||
|
||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import java.util.*
|
||||
|
||||
@ConsoleExperimentalApi
|
||||
public abstract class AbstractLoggerController : LoggerController {
|
||||
@ -25,4 +26,37 @@ public abstract class AbstractLoggerController : LoggerController {
|
||||
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean =
|
||||
shouldLog(LogPriority.by(priority), getPriority(identity))
|
||||
|
||||
@Suppress("unused")
|
||||
@ConsoleExperimentalApi
|
||||
public enum class LogPriority {
|
||||
ALL(null),
|
||||
VERBOSE,
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
NONE(null);
|
||||
|
||||
private var mapped: SimpleLogger.LogPriority? = null
|
||||
|
||||
public companion object {
|
||||
private val mapping = EnumMap<SimpleLogger.LogPriority, LogPriority>(SimpleLogger.LogPriority::class.java)
|
||||
|
||||
public fun by(priority: SimpleLogger.LogPriority): LogPriority = mapping[priority]!!
|
||||
|
||||
init {
|
||||
values().forEach { priority ->
|
||||
mapping[priority.mapped ?: return@forEach] = priority
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
constructor(void: Nothing?)
|
||||
constructor() {
|
||||
mapped = SimpleLogger.LogPriority.valueOf(name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
import java.util.*
|
||||
|
||||
public enum class LogPriority {
|
||||
ALL(null),
|
||||
VERBOSE,
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
NONE(null);
|
||||
|
||||
private var mapped: SimpleLogger.LogPriority? = null
|
||||
|
||||
public companion object {
|
||||
private val mapping = EnumMap<SimpleLogger.LogPriority, LogPriority>(SimpleLogger.LogPriority::class.java)
|
||||
|
||||
public fun by(priority: SimpleLogger.LogPriority): LogPriority = mapping[priority]!!
|
||||
|
||||
init {
|
||||
values().forEach { priority ->
|
||||
mapping[priority.mapped ?: return@forEach] = priority
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor(void: Nothing?)
|
||||
constructor() {
|
||||
mapped = SimpleLogger.LogPriority.valueOf(name)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user