mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
console.debug logger
This commit is contained in:
parent
8b6e2a1d9c
commit
d54f4cd0d9
@ -146,7 +146,7 @@ public open class AutoSavePluginData private constructor(
|
||||
}
|
||||
|
||||
internal val debuggingLogger1 by lazy {
|
||||
DefaultLogger("debug").withSwitch(false)
|
||||
DefaultLogger("console.debug").withSwitch(false)
|
||||
}
|
||||
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
|
@ -109,6 +109,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
||||
if (loggerController === LoggerControllerImpl) {
|
||||
// Reload LoggerConfig.
|
||||
ConsoleDataScope.addAndReloadConfig(LoggerConfig)
|
||||
LoggerControllerImpl.initialized = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import net.mamoe.mirai.console.command.CommandSender.Companion.toCommandSender
|
||||
import net.mamoe.mirai.console.command.descriptor.ExperimentalCommandDescriptors
|
||||
import net.mamoe.mirai.console.command.parse.CommandCallParser.Companion.parseCommandCall
|
||||
import net.mamoe.mirai.console.command.resolve.CommandCallResolver.Companion.resolve
|
||||
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
|
||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.testPermission
|
||||
import net.mamoe.mirai.console.util.CoroutineScopeUtils.childScope
|
||||
import net.mamoe.mirai.event.Listener
|
||||
@ -30,6 +31,7 @@ import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.asMessageChain
|
||||
import net.mamoe.mirai.message.data.content
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
|
||||
@OptIn(ExperimentalCommandDescriptors::class)
|
||||
@ -75,7 +77,9 @@ internal object CommandManagerImpl : CommandManager, CoroutineScope by MiraiCons
|
||||
when (val result = executeCommand(sender, message)) {
|
||||
is CommandExecuteResult.PermissionDenied -> {
|
||||
if (!result.command.prefixOptional || message.content.startsWith(CommandManager.commandPrefix)) {
|
||||
if (MiraiConsoleImplementationBridge.loggerController.shouldLog("console.debug", SimpleLogger.LogPriority.DEBUG)) {
|
||||
sender.sendMessage("权限不足")
|
||||
}
|
||||
intercept()
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ internal object LoggerConfig : AutoSavePluginConfig("Logger") {
|
||||
特定日志记录器输出等级
|
||||
""")
|
||||
val loggers: Map<String, AbstractLoggerController.LogPriority> by value(
|
||||
mapOf("example.logger" to AbstractLoggerController.LogPriority.NONE)
|
||||
mapOf(
|
||||
"example.logger" to AbstractLoggerController.LogPriority.NONE,
|
||||
"console.debug" to AbstractLoggerController.LogPriority.NONE,
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -17,11 +17,14 @@ import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||
@ConsoleFrontEndImplementation
|
||||
@ConsoleInternalApi
|
||||
internal object LoggerControllerImpl : AbstractLoggerController() {
|
||||
internal var initialized = false
|
||||
|
||||
override fun getPriority(identity: String?): LogPriority = if (identity == null) {
|
||||
override fun getPriority(identity: String?): LogPriority {
|
||||
if (!initialized) return LogPriority.NONE
|
||||
return if (identity == null) {
|
||||
LoggerConfig.defaultPriority
|
||||
} else {
|
||||
LoggerConfig.loggers[identity] ?: LoggerConfig.defaultPriority
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user