diff --git a/mirai-core/build.gradle.kts b/mirai-core/build.gradle.kts index b3ed8f9e2..addf312ea 100644 --- a/mirai-core/build.gradle.kts +++ b/mirai-core/build.gradle.kts @@ -63,10 +63,9 @@ kotlin { dependencies { implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") - implementation("io.ktor:ktor-http-cio:$ktorVersion") implementation("io.ktor:ktor-http:$ktorVersion") - implementation("io.ktor:ktor-client-core-jvm:$ktorVersion") - implementation("io.ktor:ktor-client-cio:$ktorVersion") + implementation("io.ktor:ktor-client-core:$ktorVersion") + implementation("io.ktor:ktor-client-android:$ktorVersion") } languageSettings.enableLanguageFeature("InlineClasses") @@ -87,6 +86,10 @@ kotlin { } } + sourceSets["jvmTest"].apply { + kotlin.setSrcDirs(listOf("src/$name/kotlin")) + } + sourceSets.forEach { it.languageSettings.enableLanguageFeature("InlineClasses") diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt index 80c649cb8..cbfe27600 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt @@ -60,7 +60,7 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) : override suspend fun login(configuration: BotNetworkConfiguration): LoginResult = withContext(this.coroutineContext) { TIMProtocol.SERVER_IP.forEach { ip -> - bot.logger.warning("Connecting server $ip") + bot.logger.info("Connecting server $ip") socket = BotSocketAdapter(ip, configuration) loginResult = CompletableDeferred() @@ -290,7 +290,7 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) : } } - bot.logger.info("Packet sent: $packet") + bot.logger.verbose("Packet sent: $packet") PacketSentEvent(bot, packet).broadcast() @@ -338,7 +338,7 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) : if (packet.serverIP != null) {//redirection socket.close() socket = BotSocketAdapter(packet.serverIP!!, socket.configuration) - bot.logger.warning("Redirecting to ${packet.serverIP}") + bot.logger.info("Redirecting to ${packet.serverIP}") loginResult.complete(socket.resendTouch()) } else {//password submission this.loginIP = packet.loginIP diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LoggerTextFormat.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LoggerTextFormat.kt deleted file mode 100644 index 4541ba3e6..000000000 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LoggerTextFormat.kt +++ /dev/null @@ -1,32 +0,0 @@ -package net.mamoe.mirai.utils - -/** - * @author NaturalHG - */ -enum class LoggerTextFormat(private val format: String) { - RESET("\u001b[0m"), - - BLUE("\u001b[0;34m"), - BLACK("\u001b[0;30m"), - DARK_GREY("\u001b[1;30m"), - LIGHT_BLUE("\u001b[1;34m"), - GREEN("\u001b[0;32m"), - LIGHT_GTEEN("\u001b[1;32m"), - CYAN("\u001b[0;36m"), - LIGHT_CYAN("\u001b[1;36m"), - RED("\u001b[0;31m"), - LIGHT_RED("\u001b[1;31m"), - PURPLE("\u001b[0;35m"), - LIGHT_PURPLE("\u001b[1;35m"), - BROWN("\u001b[0;33m"), - YELLOW("\u001b[1;33m"), - LIGHT_GRAY("\u001b[0;37m"), - WHITE("\u001b[1;37m"); - - override fun toString(): String { - //if(MiraiServer.getInstance().isUnix()){ - return format - // } - // return ""; - } -} diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiLoggerJvm.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiLoggerJvm.kt index 50ff00953..0fa2f77e2 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiLoggerJvm.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/MiraiLoggerJvm.kt @@ -13,19 +13,19 @@ actual typealias PlatformLogger = Console open class Console @JvmOverloads internal constructor( override val identity: String? = null ) : MiraiLoggerPlatformBase() { - override fun verbose0(any: Any?) = println(any.toString(), LoggerTextFormat.LIGHT_GRAY) + override fun verbose0(any: Any?) = println(any.toString(), LoggerTextFormat.RESET) override fun verbose0(message: String?, e: Throwable?) { verbose(message.toString()) e?.printStackTrace() } - override fun info0(any: Any?) = println(any.toString(), LoggerTextFormat.GREEN) + override fun info0(any: Any?) = println(any.toString(), LoggerTextFormat.LIGHT_GREEN) override fun info0(message: String?, e: Throwable?) { info(message.toString()) e?.printStackTrace() } - override fun warning0(any: Any?) = println(any.toString(), LoggerTextFormat.YELLOW) + override fun warning0(any: Any?) = println(any.toString(), LoggerTextFormat.LIGHT_RED) override fun warning0(message: String?, e: Throwable?) { warning(message.toString()) e?.printStackTrace() @@ -38,7 +38,7 @@ open class Console @JvmOverloads internal constructor( } override fun debug0(any: Any?) { - println(any.toString(), LoggerTextFormat.CYAN) + println(any.toString(), LoggerTextFormat.LIGHT_CYAN) } override fun debug0(message: String?, e: Throwable?) { @@ -57,6 +57,32 @@ open class Console @JvmOverloads internal constructor( } } +/** + * @author NaturalHG + */ +internal enum class LoggerTextFormat(private val format: String) { + RESET("\u001b[0m"), + + WHITE("\u001b[30m"), + RED("\u001b[31m"), + EMERALD_GREEN("\u001b[32m"), + GOLD("\u001b[33m"), + BLUE("\u001b[34m"), + PURPLE("\u001b[35m"), + GREEN("\u001b[36m"), + + GRAY("\u001b[90m"), + LIGHT_RED("\u001b[91m"), + LIGHT_GREEN("\u001b[92m"), + LIGHT_YELLOW("\u001b[93m"), + LIGHT_BLUE("\u001b[94m"), + LIGHT_PURPLE("\u001b[95m"), + LIGHT_CYAN("\u001b[96m") + ; + + override fun toString(): String = format +} + @Suppress("unused") val Throwable.stacktraceString: String get() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString() \ No newline at end of file diff --git a/mirai-core/src/jvmTest/kotlin/Run.kt b/mirai-core/src/jvmTest/kotlin/Run.kt deleted file mode 100644 index e69de29bb..000000000 diff --git a/mirai-core/src/jvmTest/kotlin/UnixColorText.kt b/mirai-core/src/jvmTest/kotlin/UnixColorText.kt new file mode 100644 index 000000000..4217f6ed1 --- /dev/null +++ b/mirai-core/src/jvmTest/kotlin/UnixColorText.kt @@ -0,0 +1,5 @@ +fun main() { + repeat(100) { + println("\u001b[1;${it}m" + it) + } +} \ No newline at end of file