Rename MiraiConsoleLoggerController to LoggerController

This commit is contained in:
Karlatemp 2020-10-25 23:00:59 +08:00
parent 1d88a9d942
commit cef1326432
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8
9 changed files with 22 additions and 23 deletions

View File

@ -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

View File

@ -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)
}
}

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)
}

View File

@ -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)
}