Optimize internal event logs

This commit is contained in:
Him188 2020-05-24 14:29:59 +08:00
parent f558537465
commit b2b8e1206a
3 changed files with 13 additions and 5 deletions

View File

@ -487,12 +487,14 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
) {
// highest priority: pass to listeners (attached by sendAndExpect).
if (packet != null && (bot.logger.isEnabled || logger.isEnabled)) {
when (packet) {
is Packet.NoLog -> {
when {
packet is Packet.NoLog -> {
// nothing to do
}
is MessageEvent -> packet.logMessageReceived()
is Event -> bot.logger.verbose { "Event: ${packet.toString().singleLine()}" }
packet is MessageEvent -> packet.logMessageReceived()
packet is Event && packet !is Packet.NoEventLog -> bot.logger.verbose {
"Event: ${packet.toString().singleLine()}"
}
else -> logger.verbose { "Recv: ${packet.toString().singleLine()}" }
}
}

View File

@ -40,7 +40,7 @@ internal class ConfigPushSvc {
) {
override val canBeCached: Boolean get() = false
sealed class PushReqResponse : Packet, Event, AbstractEvent() {
sealed class PushReqResponse : Packet, Event, AbstractEvent(), Packet.NoEventLog {
class Success(
val struct: PushReqJceStruct
) : PushReqResponse() {

View File

@ -1,5 +1,6 @@
package net.mamoe.mirai.qqandroid.network
import net.mamoe.mirai.event.Event
import net.mamoe.mirai.utils.MiraiInternalAPI
/**
@ -14,4 +15,9 @@ interface Packet {
* 实现这个接口的包将不会被记录到日志中
*/
interface NoLog
/**
* 实现这个接口的 [Event] 不会被作为事件记录到日志中
*/
interface NoEventLog
}