From 16d6c562020832277378441e05dc9985b44a7ea9 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 11 Apr 2020 18:24:52 +0800 Subject: [PATCH] Add `soutv` for debugging purposes --- .../net/mamoe/mirai/qqandroid/utils/contentToString.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/contentToString.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/contentToString.kt index 8d05fe307..1c6fdedbc 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/contentToString.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/contentToString.kt @@ -11,6 +11,8 @@ package net.mamoe.mirai.qqandroid.utils +import net.mamoe.mirai.utils.DefaultLogger +import net.mamoe.mirai.utils.debug import kotlin.reflect.KClass import kotlin.reflect.KProperty import kotlin.reflect.KProperty1 @@ -26,6 +28,12 @@ private fun Sequence.joinToStringPrefixed(prefix: String, transform: (T) return this.joinToString(prefix = "$prefix$indent", separator = "\n$prefix$indent", transform = transform) } +private val SoutvLogger by lazy { DefaultLogger("soutv") } +internal fun Any?.soutv(name: String) { + @Suppress("DEPRECATION") + SoutvLogger.debug { "$name = ${this._miraiContentToString()}" } +} + /** * 将内容格式化为较可读的字符串输出. *