Commit 659cfa22 authored by Him188's avatar Him188

Improve numbers in log

parent 16c44043
......@@ -30,6 +30,7 @@ import net.mamoe.mirai.message.data.OfflineFriendImage
import net.mamoe.mirai.message.data.isContentNotEmpty
import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.network.highway.postImage
import net.mamoe.mirai.qqandroid.network.highway.sizeToString
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x352
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.LongConn
import net.mamoe.mirai.qqandroid.utils.MiraiPlatformUtils
......@@ -109,7 +110,7 @@ internal class FriendImpl(
}
is LongConn.OffPicUp.Response.RequireUpload -> {
bot.network.logger.verbose {
"[Http] Uploading friend image, size=${image.inputSize / 1024} KiB"
"[Http] Uploading friend image, size=${image.inputSize.sizeToString()}"
}
val time = measureTime {
......
......@@ -128,7 +128,7 @@ internal object HighwayHelper {
}
) { ip, port ->
bot.network.logger.verbose {
"[Highway] Uploading $kind to ${ip}:$port, size=${inputSize / 1024} KiB"
"[Highway] Uploading $kind to ${ip}:$port, size=${inputSize.sizeToString()}"
}
val time = measureTime {
......@@ -223,4 +223,10 @@ internal suspend inline fun List<Pair<Int, Int>>.retryWithServers(
}
onFail(exception)
}
internal fun Long.sizeToString(): String {
return if (this < 1024) {
"$this B"
} else ((this * 100.0 / 1024).roundToInt() / 100.0).toString() + " KiB"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment