mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Review LoggerController
- Delete LoggerControllerPlatformBase - Rename LoggerControllerForFrontend to LoggerControllerImpl
This commit is contained in:
parent
b60ce7d856
commit
0a76a4b71a
@ -19,7 +19,7 @@ import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
|
||||
import net.mamoe.mirai.console.logging.LoggerController
|
||||
import net.mamoe.mirai.console.logging.LoggerControllerForFrontend
|
||||
import net.mamoe.mirai.console.internal.logging.LoggerControllerImpl
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
||||
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
||||
import net.mamoe.mirai.console.util.ConsoleInput
|
||||
@ -166,7 +166,7 @@ public interface MiraiConsoleImplementation : CoroutineScope {
|
||||
/**
|
||||
* 日志控制器
|
||||
*
|
||||
* @see [LoggerControllerForFrontend]
|
||||
* @see [LoggerControllerImpl]
|
||||
*/
|
||||
public val loggerController: LoggerController
|
||||
|
||||
|
@ -35,11 +35,12 @@ import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig
|
||||
import net.mamoe.mirai.console.internal.data.castOrNull
|
||||
import net.mamoe.mirai.console.internal.extension.BuiltInSingletonExtensionSelector
|
||||
import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage
|
||||
import net.mamoe.mirai.console.internal.logging.LoggerControllerImpl
|
||||
import net.mamoe.mirai.console.internal.logging.MiraiConsoleLogger
|
||||
import net.mamoe.mirai.console.internal.permission.BuiltInPermissionService
|
||||
import net.mamoe.mirai.console.internal.plugin.PluginManagerImpl
|
||||
import net.mamoe.mirai.console.internal.util.autoHexToBytes
|
||||
import net.mamoe.mirai.console.logging.*
|
||||
import net.mamoe.mirai.console.internal.logging.MiraiConsoleLogger
|
||||
import net.mamoe.mirai.console.logging.LoggerController
|
||||
import net.mamoe.mirai.console.permission.PermissionService
|
||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.permit
|
||||
import net.mamoe.mirai.console.permission.RootPermission
|
||||
@ -103,7 +104,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
||||
@Suppress("RemoveRedundantBackticks")
|
||||
internal fun doStart() {
|
||||
phase `setup logger controller`@{
|
||||
if (loggerController is LoggerControllerForFrontend) {
|
||||
if (loggerController is LoggerControllerImpl) {
|
||||
ConsoleDataScope.addAndReloadConfig(LoggerConfig)
|
||||
}
|
||||
}
|
||||
|
@ -8,16 +8,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.logging
|
||||
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.LoggerController
|
||||
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
|
||||
@ConsoleFrontEndImplementation
|
||||
@ConsoleInternalApi
|
||||
public abstract class LoggerControllerForFrontend : LoggerControllerPlatformBase() {
|
||||
public abstract class LoggerControllerImpl : LoggerController {
|
||||
|
||||
private fun shouldLog(
|
||||
priority: LoggerConfig.LogPriority,
|
@ -12,22 +12,22 @@ package net.mamoe.mirai.console.logging
|
||||
|
||||
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
|
||||
import net.mamoe.mirai.console.MiraiConsole
|
||||
import net.mamoe.mirai.console.internal.logging.LoggerControllerImpl
|
||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
/**
|
||||
* 日志控制系统
|
||||
*
|
||||
* @see [LoggerControllerPlatformBase]
|
||||
* @see [LoggerControllerForFrontend]
|
||||
* @see [LoggerControllerImpl]
|
||||
*/
|
||||
@ConsoleExperimentalApi
|
||||
@ConsoleFrontEndImplementation
|
||||
public interface LoggerController {
|
||||
/** 是否应该记录该等级的日志 */
|
||||
public fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean
|
||||
|
||||
/**
|
||||
* 创建一个新的 [MiraiLogger]
|
||||
*
|
||||
|
@ -1,27 +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 via the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.logging
|
||||
|
||||
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
|
||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@ConsoleExperimentalApi
|
||||
@ConsoleFrontEndImplementation
|
||||
public abstract class LoggerControllerPlatformBase : LoggerController {
|
||||
|
||||
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true
|
||||
|
||||
}
|
@ -15,7 +15,6 @@ import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.data.MemoryPluginDataStorage
|
||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||
import net.mamoe.mirai.console.logging.LoggerController
|
||||
import net.mamoe.mirai.console.logging.LoggerControllerPlatformBase
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
||||
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||
@ -72,7 +71,7 @@ fun initTestEnvironment() {
|
||||
override fun createLoginSolver(requesterBot: Long, configuration: BotConfiguration): LoginSolver =
|
||||
LoginSolver.Default
|
||||
|
||||
override val loggerController: LoggerController = object : LoggerControllerPlatformBase() {
|
||||
override val loggerController: LoggerController = object : LoggerController {
|
||||
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true
|
||||
override fun newLogger(identity: String?): MiraiLogger = PlatformLogger(identity)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import net.mamoe.mirai.console.MiraiConsoleImplementation
|
||||
import net.mamoe.mirai.console.data.MultiFilePluginDataStorage
|
||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||
import net.mamoe.mirai.console.logging.LoggerController
|
||||
import net.mamoe.mirai.console.logging.LoggerControllerForFrontend
|
||||
import net.mamoe.mirai.console.internal.logging.LoggerControllerImpl
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
||||
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
||||
import net.mamoe.mirai.console.terminal.ConsoleInputImpl.requestInput
|
||||
@ -83,7 +83,7 @@ class MiraiConsoleImplementationTerminal
|
||||
return DefaultLoginSolver(input = { requestInput("LOGIN> ") })
|
||||
}
|
||||
|
||||
override val loggerController: LoggerController = object : LoggerControllerForFrontend() {
|
||||
override val loggerController: LoggerController = object : LoggerControllerImpl() {
|
||||
override fun newLogger(identity: String?): MiraiLogger = LoggerCreator(identity)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user