mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Rename MiraiConsoleLoggerController to LoggerController
This commit is contained in:
parent
1d88a9d942
commit
cef1326432
@ -18,8 +18,8 @@ import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
|
|||||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||||
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
|
import net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerController
|
import net.mamoe.mirai.console.logging.LoggerController
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerForFrontend
|
import net.mamoe.mirai.console.logging.LoggerControllerForFrontend
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
||||||
import net.mamoe.mirai.console.util.ConsoleInput
|
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 {
|
public companion object {
|
||||||
internal lateinit var instance: MiraiConsoleImplementation
|
internal lateinit var instance: MiraiConsoleImplementation
|
||||||
|
@ -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.permission.BuiltInPermissionService
|
||||||
import net.mamoe.mirai.console.internal.plugin.PluginManagerImpl
|
import net.mamoe.mirai.console.internal.plugin.PluginManagerImpl
|
||||||
import net.mamoe.mirai.console.internal.util.autoHexToBytes
|
import net.mamoe.mirai.console.internal.util.autoHexToBytes
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerController
|
import net.mamoe.mirai.console.logging.LoggerController
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerForFrontend
|
import net.mamoe.mirai.console.logging.LoggerControllerForFrontend
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerUnused
|
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerUnused
|
||||||
import net.mamoe.mirai.console.logging.MiraiDelegateLogger
|
import net.mamoe.mirai.console.logging.MiraiDelegateLogger
|
||||||
import net.mamoe.mirai.console.permission.PermissionService
|
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 dataStorageForBuiltIns: PluginDataStorage by instance::dataStorageForBuiltIns
|
||||||
override val configStorageForBuiltIns: PluginDataStorage by instance::configStorageForBuiltIns
|
override val configStorageForBuiltIns: PluginDataStorage by instance::configStorageForBuiltIns
|
||||||
override val consoleInput: ConsoleInput by instance::consoleInput
|
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 =
|
override fun createLoginSolver(requesterBot: Long, configuration: BotConfiguration): LoginSolver =
|
||||||
instance.createLoginSolver(requesterBot, configuration)
|
instance.createLoginSolver(requesterBot, configuration)
|
||||||
@ -108,7 +108,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
|||||||
@Suppress("RemoveRedundantBackticks")
|
@Suppress("RemoveRedundantBackticks")
|
||||||
internal fun doStart() {
|
internal fun doStart() {
|
||||||
phase `setup logger controller`@{
|
phase `setup logger controller`@{
|
||||||
if (loggerController is MiraiConsoleLoggerControllerForFrontend) {
|
if (loggerController is LoggerControllerForFrontend) {
|
||||||
ConsoleDataScope.addAndReloadConfig(LoggerConfig)
|
ConsoleDataScope.addAndReloadConfig(LoggerConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,12 @@ import java.util.concurrent.atomic.AtomicReference
|
|||||||
/**
|
/**
|
||||||
* 日志控制系统
|
* 日志控制系统
|
||||||
*
|
*
|
||||||
* @see [MiraiConsoleLoggerControllerPlatformBase]
|
* @see [LoggerControllerPlatformBase]
|
||||||
* @see [MiraiConsoleLoggerControllerForFrontend]
|
* @see [LoggerControllerForFrontend]
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
||||||
@ConsoleFrontEndImplementation
|
@ConsoleFrontEndImplementation
|
||||||
public interface MiraiConsoleLoggerController {
|
public interface LoggerController {
|
||||||
/** 是否应该记录该等级的日志 */
|
/** 是否应该记录该等级的日志 */
|
||||||
public fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean
|
public fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean
|
||||||
/** 是否应该对 [newLogger] 的结果进行缓存 */
|
/** 是否应该对 [newLogger] 的结果进行缓存 */
|
||||||
@ -39,7 +39,7 @@ public interface MiraiConsoleLoggerController {
|
|||||||
* - 即不需要在此方法中把 [MiraiLogger] 放入任意缓存
|
* - 即不需要在此方法中把 [MiraiLogger] 放入任意缓存
|
||||||
*
|
*
|
||||||
* * **注意**: [MiraiConsole] 会将 [net.mamoe.mirai.utils.DefaultLogger] 设置为 `MiraiConsole::createLogger`.
|
* * **注意**: [MiraiConsole] 会将 [net.mamoe.mirai.utils.DefaultLogger] 设置为 `MiraiConsole::createLogger`.
|
||||||
* `MiraiConsole::createLogger` 会使用 [MiraiConsoleLoggerController.newLogger]
|
* `MiraiConsole::createLogger` 会使用 [LoggerController.newLogger]
|
||||||
* 因此不要在 [newLogger] 中调用 [net.mamoe.mirai.utils.DefaultLogger]
|
* 因此不要在 [newLogger] 中调用 [net.mamoe.mirai.utils.DefaultLogger]
|
||||||
*/
|
*/
|
||||||
public fun newLogger(identity: String?): MiraiLogger
|
public fun newLogger(identity: String?): MiraiLogger
|
@ -11,14 +11,13 @@
|
|||||||
package net.mamoe.mirai.console.logging
|
package net.mamoe.mirai.console.logging
|
||||||
|
|
||||||
import net.mamoe.mirai.console.ConsoleFrontEndImplementation
|
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.internal.data.builtins.LoggerConfig
|
||||||
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
import net.mamoe.mirai.console.util.ConsoleInternalApi
|
||||||
import net.mamoe.mirai.utils.SimpleLogger
|
import net.mamoe.mirai.utils.SimpleLogger
|
||||||
|
|
||||||
@ConsoleFrontEndImplementation
|
@ConsoleFrontEndImplementation
|
||||||
@ConsoleInternalApi
|
@ConsoleInternalApi
|
||||||
public abstract class MiraiConsoleLoggerControllerForFrontend : MiraiConsoleLoggerControllerPlatformBase() {
|
public abstract class LoggerControllerForFrontend : LoggerControllerPlatformBase() {
|
||||||
|
|
||||||
private fun shouldLog(
|
private fun shouldLog(
|
||||||
priority: LoggerConfig.LogPriority,
|
priority: LoggerConfig.LogPriority,
|
@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicReference
|
|||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
||||||
@ConsoleFrontEndImplementation
|
@ConsoleFrontEndImplementation
|
||||||
public abstract class MiraiConsoleLoggerControllerPlatformBase : MiraiConsoleLoggerController {
|
public abstract class LoggerControllerPlatformBase : LoggerController {
|
||||||
|
|
||||||
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true
|
override fun shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true
|
||||||
override val cacheLoggers: Boolean get() = true
|
override val cacheLoggers: Boolean get() = true
|
@ -15,7 +15,7 @@ import net.mamoe.mirai.utils.MiraiLoggerPlatformBase
|
|||||||
import net.mamoe.mirai.utils.SimpleLogger
|
import net.mamoe.mirai.utils.SimpleLogger
|
||||||
|
|
||||||
internal class MiraiConsoleLogger(
|
internal class MiraiConsoleLogger(
|
||||||
private val controller: MiraiConsoleLoggerController,
|
private val controller: LoggerController,
|
||||||
val logger: MiraiLogger
|
val logger: MiraiLogger
|
||||||
) : MiraiLoggerPlatformBase() {
|
) : MiraiLoggerPlatformBase() {
|
||||||
override val identity: String? get() = logger.identity
|
override val identity: String? get() = logger.identity
|
||||||
|
@ -14,7 +14,7 @@ import net.mamoe.mirai.utils.MiraiLogger
|
|||||||
import net.mamoe.mirai.utils.MiraiLoggerPlatformBase
|
import net.mamoe.mirai.utils.MiraiLoggerPlatformBase
|
||||||
|
|
||||||
internal class MiraiConsoleLoggerUnused(
|
internal class MiraiConsoleLoggerUnused(
|
||||||
val controller: MiraiConsoleLoggerController,
|
val controller: LoggerController,
|
||||||
override val identity: String?
|
override val identity: String?
|
||||||
) : MiraiLoggerPlatformBase() {
|
) : MiraiLoggerPlatformBase() {
|
||||||
internal object InitializeLock
|
internal object InitializeLock
|
||||||
|
@ -14,8 +14,8 @@ import net.mamoe.mirai.console.MiraiConsoleImplementation.Companion.start
|
|||||||
import net.mamoe.mirai.console.command.CommandManager
|
import net.mamoe.mirai.console.command.CommandManager
|
||||||
import net.mamoe.mirai.console.data.MemoryPluginDataStorage
|
import net.mamoe.mirai.console.data.MemoryPluginDataStorage
|
||||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerController
|
import net.mamoe.mirai.console.logging.LoggerController
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerPlatformBase
|
import net.mamoe.mirai.console.logging.LoggerControllerPlatformBase
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
||||||
@ -72,7 +72,7 @@ fun initTestEnvironment() {
|
|||||||
override fun createLoginSolver(requesterBot: Long, configuration: BotConfiguration): LoginSolver =
|
override fun createLoginSolver(requesterBot: Long, configuration: BotConfiguration): LoginSolver =
|
||||||
LoginSolver.Default
|
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 shouldLog(identity: String?, priority: SimpleLogger.LogPriority): Boolean = true
|
||||||
override fun newLogger(identity: String?): MiraiLogger = PlatformLogger(identity)
|
override fun newLogger(identity: String?): MiraiLogger = PlatformLogger(identity)
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ import net.mamoe.mirai.console.MiraiConsoleFrontEndDescription
|
|||||||
import net.mamoe.mirai.console.MiraiConsoleImplementation
|
import net.mamoe.mirai.console.MiraiConsoleImplementation
|
||||||
import net.mamoe.mirai.console.data.MultiFilePluginDataStorage
|
import net.mamoe.mirai.console.data.MultiFilePluginDataStorage
|
||||||
import net.mamoe.mirai.console.data.PluginDataStorage
|
import net.mamoe.mirai.console.data.PluginDataStorage
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerController
|
import net.mamoe.mirai.console.logging.LoggerController
|
||||||
import net.mamoe.mirai.console.logging.MiraiConsoleLoggerControllerForFrontend
|
import net.mamoe.mirai.console.logging.LoggerControllerForFrontend
|
||||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
import net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader
|
||||||
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
import net.mamoe.mirai.console.plugin.loader.PluginLoader
|
||||||
import net.mamoe.mirai.console.terminal.ConsoleInputImpl.requestInput
|
import net.mamoe.mirai.console.terminal.ConsoleInputImpl.requestInput
|
||||||
@ -83,7 +83,7 @@ class MiraiConsoleImplementationTerminal
|
|||||||
return DefaultLoginSolver(input = { requestInput("LOGIN> ") })
|
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)
|
override fun newLogger(identity: String?): MiraiLogger = LoggerCreator(identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user