From 50e60cc4fe5204145987d0ec4e124da2ecb1769b Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 3 Apr 2021 23:07:41 +0800 Subject: [PATCH] Use system property `mirai.unknown.image.type.logging` to enable logging on unknown image type, helps #1111 --- .../src/commonMain/kotlin/message/imagesImpl.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/message/imagesImpl.kt b/mirai-core/src/commonMain/kotlin/message/imagesImpl.kt index d2ba26cf5..aa2ebc35b 100644 --- a/mirai-core/src/commonMain/kotlin/message/imagesImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/imagesImpl.kt @@ -117,6 +117,8 @@ OnlineFriendImage() { * SHARPP: 1004 */ +internal val UNKNOWN_IMAGE_TYPE_PROMPT_ENABLED = systemProp("mirai.unknown.image.type.logging", false) + internal fun getImageType(id: Int): String { return when (id) { 1000 -> "jpg" @@ -125,7 +127,15 @@ internal fun getImageType(id: Int): String { 1005 -> "bmp" 2000 -> "gif" 2001, 3 -> "png" - else -> DEFAULT_FORMAT_NAME + else -> { + if (UNKNOWN_IMAGE_TYPE_PROMPT_ENABLED) { + MiraiLogger.TopLevel.debug( + "Unknown image id: $id. Stacktrace:", + Exception() + ) + } + DEFAULT_FORMAT_NAME + } } }