mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 09:10:11 +08:00
adjust logger colors
This commit is contained in:
parent
dd0501521c
commit
e2171fd158
@ -63,10 +63,9 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
||||||
|
|
||||||
implementation("io.ktor:ktor-http-cio:$ktorVersion")
|
|
||||||
implementation("io.ktor:ktor-http:$ktorVersion")
|
implementation("io.ktor:ktor-http:$ktorVersion")
|
||||||
implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
|
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
||||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
implementation("io.ktor:ktor-client-android:$ktorVersion")
|
||||||
|
|
||||||
}
|
}
|
||||||
languageSettings.enableLanguageFeature("InlineClasses")
|
languageSettings.enableLanguageFeature("InlineClasses")
|
||||||
@ -87,6 +86,10 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets["jvmTest"].apply {
|
||||||
|
kotlin.setSrcDirs(listOf("src/$name/kotlin"))
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets.forEach {
|
sourceSets.forEach {
|
||||||
it.languageSettings.enableLanguageFeature("InlineClasses")
|
it.languageSettings.enableLanguageFeature("InlineClasses")
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
|
|||||||
|
|
||||||
override suspend fun login(configuration: BotNetworkConfiguration): LoginResult = withContext(this.coroutineContext) {
|
override suspend fun login(configuration: BotNetworkConfiguration): LoginResult = withContext(this.coroutineContext) {
|
||||||
TIMProtocol.SERVER_IP.forEach { ip ->
|
TIMProtocol.SERVER_IP.forEach { ip ->
|
||||||
bot.logger.warning("Connecting server $ip")
|
bot.logger.info("Connecting server $ip")
|
||||||
socket = BotSocketAdapter(ip, configuration)
|
socket = BotSocketAdapter(ip, configuration)
|
||||||
|
|
||||||
loginResult = CompletableDeferred()
|
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()
|
PacketSentEvent(bot, packet).broadcast()
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
|
|||||||
if (packet.serverIP != null) {//redirection
|
if (packet.serverIP != null) {//redirection
|
||||||
socket.close()
|
socket.close()
|
||||||
socket = BotSocketAdapter(packet.serverIP!!, socket.configuration)
|
socket = BotSocketAdapter(packet.serverIP!!, socket.configuration)
|
||||||
bot.logger.warning("Redirecting to ${packet.serverIP}")
|
bot.logger.info("Redirecting to ${packet.serverIP}")
|
||||||
loginResult.complete(socket.resendTouch())
|
loginResult.complete(socket.resendTouch())
|
||||||
} else {//password submission
|
} else {//password submission
|
||||||
this.loginIP = packet.loginIP
|
this.loginIP = packet.loginIP
|
||||||
|
@ -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 "";
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,19 +13,19 @@ actual typealias PlatformLogger = Console
|
|||||||
open class Console @JvmOverloads internal constructor(
|
open class Console @JvmOverloads internal constructor(
|
||||||
override val identity: String? = null
|
override val identity: String? = null
|
||||||
) : MiraiLoggerPlatformBase() {
|
) : 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?) {
|
override fun verbose0(message: String?, e: Throwable?) {
|
||||||
verbose(message.toString())
|
verbose(message.toString())
|
||||||
e?.printStackTrace()
|
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?) {
|
override fun info0(message: String?, e: Throwable?) {
|
||||||
info(message.toString())
|
info(message.toString())
|
||||||
e?.printStackTrace()
|
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?) {
|
override fun warning0(message: String?, e: Throwable?) {
|
||||||
warning(message.toString())
|
warning(message.toString())
|
||||||
e?.printStackTrace()
|
e?.printStackTrace()
|
||||||
@ -38,7 +38,7 @@ open class Console @JvmOverloads internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun debug0(any: Any?) {
|
override fun debug0(any: Any?) {
|
||||||
println(any.toString(), LoggerTextFormat.CYAN)
|
println(any.toString(), LoggerTextFormat.LIGHT_CYAN)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun debug0(message: String?, e: Throwable?) {
|
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")
|
@Suppress("unused")
|
||||||
val Throwable.stacktraceString: String
|
val Throwable.stacktraceString: String
|
||||||
get() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString()
|
get() = ByteArrayOutputStream().also { printStackTrace(PrintStream(it)) }.toString()
|
5
mirai-core/src/jvmTest/kotlin/UnixColorText.kt
Normal file
5
mirai-core/src/jvmTest/kotlin/UnixColorText.kt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
fun main() {
|
||||||
|
repeat(100) {
|
||||||
|
println("\u001b[1;${it}m" + it)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user