mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-12 22:10:14 +08:00
Improve numbers in log
This commit is contained in:
parent
16c440433f
commit
659cfa2288
@ -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"
|
||||
}
|
Loading…
Reference in New Issue
Block a user