diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleFrontEndPure.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleFrontEndPure.kt index 850bff7a5..e8dc2ef2e 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleFrontEndPure.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsoleFrontEndPure.kt @@ -13,18 +13,26 @@ package net.mamoe.mirai.console.pure //import net.mamoe.mirai.console.utils.MiraiConsoleFrontEnd import net.mamoe.mirai.Bot import net.mamoe.mirai.console.MiraiConsoleFrontEnd -import net.mamoe.mirai.utils.DefaultLogger import net.mamoe.mirai.utils.DefaultLoginSolver import net.mamoe.mirai.utils.LoginSolver import net.mamoe.mirai.utils.MiraiLogger +import net.mamoe.mirai.utils.PlatformLogger import org.fusesource.jansi.Ansi import java.text.SimpleDateFormat import java.util.* import java.util.concurrent.ConcurrentHashMap +private val ANSI_RESET = Ansi().reset().toString() + +internal val LoggerCreator: (identity: String?) -> MiraiLogger = { + PlatformLogger(identity = it, output = { line -> + ConsoleUtils.lineReader.printAbove(line + ANSI_RESET) + }) +} + @Suppress("unused") object MiraiConsoleFrontEndPure : MiraiConsoleFrontEnd { - private val globalLogger = DefaultLogger("Mirai") + private val globalLogger = LoggerCreator("Mirai") private val cachedLoggers = ConcurrentHashMap() // companion object { @@ -49,7 +57,7 @@ object MiraiConsoleFrontEndPure : MiraiConsoleFrontEnd { override fun loggerFor(identity: String?): MiraiLogger { identity?.apply { - return cachedLoggers.computeIfAbsent(this, DefaultLogger) + return cachedLoggers.computeIfAbsent(this, LoggerCreator) } return globalLogger } @@ -82,7 +90,6 @@ object MiraiConsoleFrontEndPure : MiraiConsoleFrontEnd { } ) } - } /* diff --git a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt index 72dd8c6fa..5d0e58f2d 100644 --- a/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt +++ b/frontend/mirai-console-pure/src/main/kotlin/net/mamoe/mirai/console/pure/MiraiConsolePureLoader.kt @@ -36,18 +36,8 @@ object MiraiConsolePureLoader { } } -private val ANSI_RESET = Ansi().reset().toString() - -internal fun overrideLoggingSystem() { - DefaultLogger = { - PlatformLogger(identity = it, output = { line -> - ConsoleUtils.lineReader.printAbove(line + ANSI_RESET) - }) - } -} internal fun startup() { - overrideLoggingSystem() MiraiConsoleInitializer.init(MiraiConsolePure) startConsoleThread() }