From cef1326432e1684133efd4ea75efff8bfddc8a50 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Sun, 25 Oct 2020 23:00:59 +0800 Subject: [PATCH] Rename MiraiConsoleLoggerController to LoggerController --- .../net/mamoe/mirai/console/MiraiConsoleImplementation.kt | 8 ++++---- .../console/internal/MiraiConsoleImplementationBridge.kt | 8 ++++---- ...iraiConsoleLoggerController.kt => LoggerController.kt} | 8 ++++---- ...ollerForFrontend.kt => LoggerControllerForFrontend.kt} | 3 +-- ...lerPlatformBase.kt => LoggerControllerPlatformBase.kt} | 2 +- .../net/mamoe/mirai/console/logging/MiraiConsoleLogger.kt | 2 +- .../mirai/console/logging/MiraiConsoleLoggerUnused.kt | 2 +- .../kotlin/net/mamoe/mirai/console/TestMiraiConosle.kt | 6 +++--- .../terminal/MiraiConsoleImplementationTerminal.kt | 6 +++--- 9 files changed, 22 insertions(+), 23 deletions(-) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/{MiraiConsoleLoggerController.kt => LoggerController.kt} (89%) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/{MiraiConsoleLoggerControllerForFrontend.kt => LoggerControllerForFrontend.kt} (88%) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/{MiraiConsoleLoggerControllerPlatformBase.kt => LoggerControllerPlatformBase.kt} (93%) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt index 74dfe8501..9fcc73a41 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/MiraiConsoleImplementation.kt @@ -18,8 +18,8 @@ import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start 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.MiraiConsoleLoggerController -import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerForFrontend +import net.mamoe.mirai.console.logging.LoggerController +import net.mamoe.mirai.console.logging.LoggerControllerForFrontend import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader import net.mamoe.mirai.console.plugin.loader.PluginLoader import net.mamoe.mirai.console.util.ConsoleInput @@ -165,9 +165,9 @@ public interface MiraiConsoleImplementation : CoroutineScope { /** * 日志控制器 * - * @see [MiraiConsoleLoggerControllerForFrontend] + * @see [LoggerControllerForFrontend] */ - public val loggerController: MiraiConsoleLoggerController + public val loggerController: LoggerController public companion object { internal lateinit var instance: MiraiConsoleImplementation diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt index 628d06c2d..d4ea82228 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/MiraiConsoleImplementationBridge.kt @@ -38,8 +38,8 @@ import net.mamoe.mirai.console.internal.extension.GlobalComponentStorage 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.MiraiConsoleLoggerController -import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerForFrontend +import net.mamoe.mirai.console.logging.LoggerController +import net.mamoe.mirai.console.logging.LoggerControllerForFrontend import net.mamoe.mirai.console.logging.MiraiConsoleLoggerUnused import net.mamoe.mirai.console.logging.MiraiDelegateLogger import net.mamoe.mirai.console.permission.PermissionService @@ -87,7 +87,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI override val dataStorageForBuiltIns: PluginDataStorage by instance::dataStorageForBuiltIns override val configStorageForBuiltIns: PluginDataStorage by instance::configStorageForBuiltIns override val consoleInput: ConsoleInput by instance::consoleInput - override val loggerController: MiraiConsoleLoggerController by instance::loggerController + override val loggerController: LoggerController by instance::loggerController override fun createLoginSolver(requesterBot: Long, configuration: BotConfiguration): LoginSolver = instance.createLoginSolver(requesterBot, configuration) @@ -108,7 +108,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI @Suppress("RemoveRedundantBackticks") internal fun doStart() { phase `setup logger controller`@{ - if (loggerController is MiraiConsoleLoggerControllerForFrontend) { + if (loggerController is LoggerControllerForFrontend) { ConsoleDataScope.addAndReloadConfig(LoggerConfig) } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerController.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerController.kt similarity index 89% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerController.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerController.kt index 463ec0276..1eaecff5c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerController.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerController.kt @@ -20,12 +20,12 @@ import java.util.concurrent.atomic.AtomicReference /** * 日志控制系统 * - * @see [MiraiConsoleLoggerControllerPlatformBase] - * @see [MiraiConsoleLoggerControllerForFrontend] + * @see [LoggerControllerPlatformBase] + * @see [LoggerControllerForFrontend] */ @ConsoleExperimentalApi @ConsoleFrontEndImplementation -public interface MiraiConsoleLoggerController { +public interface LoggerController { /** 是否应该记录该等级的日志 */ public fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean /** 是否应该对 [newLogger] 的结果进行缓存 */ @@ -39,7 +39,7 @@ public interface MiraiConsoleLoggerController { * - 即不需要在此方法中把 [MiraiLogger] 放入任意缓存 * * * **注意**: [MiraiConsole] 会将 [net.mamoe.mirai.utils.DefaultLogger] 设置为 `MiraiConsole::createLogger`. - * `MiraiConsole::createLogger` 会使用 [MiraiConsoleLoggerController.newLogger] + * `MiraiConsole::createLogger` 会使用 [LoggerController.newLogger] * 因此不要在 [newLogger] 中调用 [net.mamoe.mirai.utils.DefaultLogger] */ public fun newLogger(identity: String?): MiraiLogger diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerControllerForFrontend.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerControllerForFrontend.kt similarity index 88% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerControllerForFrontend.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerControllerForFrontend.kt index 58ee58c7e..89bd913ba 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerControllerForFrontend.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerControllerForFrontend.kt @@ -11,14 +11,13 @@ package net.mamoe.mirai.console.logging import net.mamoe.mirai.console.ConsoleFrontEndImplementation -import net.mamoe.mirai.console.internal.data.builtins.ConsoleDataScope import net.mamoe.mirai.console.internal.data.builtins.LoggerConfig import net.mamoe.mirai.console.util.ConsoleInternalApi import net.mamoe.mirai.utils.SimpleLogger @ConsoleFrontEndImplementation @ConsoleInternalApi -public abstract class MiraiConsoleLoggerControllerForFrontend : MiraiConsoleLoggerControllerPlatformBase() { +public abstract class LoggerControllerForFrontend : LoggerControllerPlatformBase() { private fun shouldLog( priority: LoggerConfig.LogPriority, diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerControllerPlatformBase.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerControllerPlatformBase.kt similarity index 93% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerControllerPlatformBase.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerControllerPlatformBase.kt index f7753e0ee..a77b0860c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerControllerPlatformBase.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/LoggerControllerPlatformBase.kt @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicReference @Suppress("MemberVisibilityCanBePrivate") @ConsoleExperimentalApi @ConsoleFrontEndImplementation -public abstract class MiraiConsoleLoggerControllerPlatformBase : MiraiConsoleLoggerController { +public abstract class LoggerControllerPlatformBase : LoggerController { override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true override val cacheLoggers: Boolean get() = true diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLogger.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLogger.kt index 2c2bcf531..de35aeac4 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLogger.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLogger.kt @@ -15,7 +15,7 @@ import net.mamoe.mirai.utils.MiraiLoggerPlatformBase import net.mamoe.mirai.utils.SimpleLogger internal class MiraiConsoleLogger( - private val controller: MiraiConsoleLoggerController, + private val controller: LoggerController, val logger: MiraiLogger ) : MiraiLoggerPlatformBase() { override val identity: String? get() = logger.identity diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerUnused.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerUnused.kt index 3fc98e568..d2caa896e 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerUnused.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/logging/MiraiConsoleLoggerUnused.kt @@ -14,7 +14,7 @@ import net.mamoe.mirai.utils.MiraiLogger import net.mamoe.mirai.utils.MiraiLoggerPlatformBase internal class MiraiConsoleLoggerUnused( - val controller: MiraiConsoleLoggerController, + val controller: LoggerController, override val identity: String? ) : MiraiLoggerPlatformBase() { internal object InitializeLock diff --git a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/TestMiraiConosle.kt b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/TestMiraiConosle.kt index 9499e373e..9af2aa7e2 100644 --- a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/TestMiraiConosle.kt +++ b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/TestMiraiConosle.kt @@ -14,8 +14,8 @@ import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start 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.MiraiConsoleLoggerController -import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerPlatformBase +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 +72,7 @@ fun initTestEnvironment() { override fun createLoginSolver(requesterBot: Long, configuration: BotConfiguration): LoginSolver = LoginSolver.Default - override val loggerController: MiraiConsoleLoggerController = object:MiraiConsoleLoggerControllerPlatformBase(){ + override val loggerController: LoggerController = object:LoggerControllerPlatformBase(){ override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true override fun newLogger(identity: String?): MiraiLogger = PlatformLogger(identity) } diff --git a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt index 6d756f13e..642e12e45 100644 --- a/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt +++ b/frontend/mirai-console-terminal/src/main/kotlin/net/mamoe/mirai/console/terminal/MiraiConsoleImplementationTerminal.kt @@ -33,8 +33,8 @@ import net.mamoe.mirai.console.MiraiConsoleFrontEndDescription 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.MiraiConsoleLoggerController -import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerForFrontend +import net.mamoe.mirai.console.logging.LoggerController +import net.mamoe.mirai.console.logging.LoggerControllerForFrontend 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: MiraiConsoleLoggerController = object : MiraiConsoleLoggerControllerForFrontend() { + override val loggerController: LoggerController = object : LoggerControllerForFrontend() { override fun newLogger(identity: String?): MiraiLogger = LoggerCreator(identity) }