mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 15:49:15 +08:00
Hide event logs that are too verbose
Co-authored-by: Him188 <Him188@mamoe.net>
This commit is contained in:
parent
238ec52eea
commit
7fe402695e
@ -1900,7 +1900,7 @@ public final class net/mamoe/mirai/event/SyncFromEventKt {
|
||||
public static final synthetic fun syncFromEventImpl (Lkotlin/reflect/KClass;Lkotlinx/coroutines/CoroutineScope;Lnet/mamoe/mirai/event/EventPriority;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class net/mamoe/mirai/event/events/BeforeImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public final class net/mamoe/mirai/event/events/BeforeImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public final fun component1 ()Lnet/mamoe/mirai/contact/Contact;
|
||||
public final fun component2 ()Lnet/mamoe/mirai/utils/ExternalResource;
|
||||
public final fun copy (Lnet/mamoe/mirai/contact/Contact;Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/event/events/BeforeImageUploadEvent;
|
||||
@ -2147,7 +2147,7 @@ public abstract interface class net/mamoe/mirai/event/events/FriendEvent : net/m
|
||||
public synthetic fun getUser ()Lnet/mamoe/mirai/contact/User;
|
||||
}
|
||||
|
||||
public final class net/mamoe/mirai/event/events/FriendInputStatusChangedEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/FriendEvent, net/mamoe/mirai/internal/network/Packet {
|
||||
public final class net/mamoe/mirai/event/events/FriendInputStatusChangedEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/FriendEvent, net/mamoe/mirai/internal/event/VerboseEvent, net/mamoe/mirai/internal/network/Packet {
|
||||
public final fun component1 ()Lnet/mamoe/mirai/contact/Friend;
|
||||
public final fun component2 ()Z
|
||||
public final fun copy (Lnet/mamoe/mirai/contact/Friend;Z)Lnet/mamoe/mirai/event/events/FriendInputStatusChangedEvent;
|
||||
@ -2537,7 +2537,7 @@ public final class net/mamoe/mirai/event/events/GroupTempMessageSyncEvent : net/
|
||||
public fun getTime ()I
|
||||
}
|
||||
|
||||
public abstract class net/mamoe/mirai/event/events/ImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public abstract class net/mamoe/mirai/event/events/ImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public abstract fun getSource ()Lnet/mamoe/mirai/utils/ExternalResource;
|
||||
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||
@ -2801,7 +2801,7 @@ public abstract interface class net/mamoe/mirai/event/events/MessageEvent : net/
|
||||
public abstract fun getTime ()I
|
||||
}
|
||||
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePostSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePostSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public final fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public abstract fun getException ()Ljava/lang/Throwable;
|
||||
public abstract fun getMessage ()Lnet/mamoe/mirai/message/data/MessageChain;
|
||||
@ -2809,7 +2809,7 @@ public abstract class net/mamoe/mirai/event/events/MessagePostSendEvent : net/ma
|
||||
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||
}
|
||||
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePreSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePreSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public final fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public abstract fun getMessage ()Lnet/mamoe/mirai/message/data/Message;
|
||||
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||
@ -5440,6 +5440,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
|
||||
public final fun getWorkingDir ()Ljava/io/File;
|
||||
public final synthetic fun inheritCoroutineContext (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun isConvertLineSeparator ()Z
|
||||
public final fun isShowingVerboseEventLog ()Z
|
||||
public final fun loadDeviceInfoJson (Ljava/lang/String;)V
|
||||
public final fun noBotLog ()V
|
||||
public final fun noNetworkLog ()V
|
||||
@ -5481,6 +5482,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
|
||||
public final fun setProtocol (Lnet/mamoe/mirai/utils/BotConfiguration$MiraiProtocol;)V
|
||||
public final fun setReconnectPeriodMillis (J)V
|
||||
public final fun setReconnectionRetryTimes (I)V
|
||||
public final fun setShowingVerboseEventLog (Z)V
|
||||
public final fun setStatHeartbeatPeriodMillis (J)V
|
||||
public final fun setWorkingDir (Ljava/io/File;)V
|
||||
}
|
||||
|
@ -1900,7 +1900,7 @@ public final class net/mamoe/mirai/event/SyncFromEventKt {
|
||||
public static final synthetic fun syncFromEventImpl (Lkotlin/reflect/KClass;Lkotlinx/coroutines/CoroutineScope;Lnet/mamoe/mirai/event/EventPriority;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class net/mamoe/mirai/event/events/BeforeImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public final class net/mamoe/mirai/event/events/BeforeImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public final fun component1 ()Lnet/mamoe/mirai/contact/Contact;
|
||||
public final fun component2 ()Lnet/mamoe/mirai/utils/ExternalResource;
|
||||
public final fun copy (Lnet/mamoe/mirai/contact/Contact;Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/event/events/BeforeImageUploadEvent;
|
||||
@ -2147,7 +2147,7 @@ public abstract interface class net/mamoe/mirai/event/events/FriendEvent : net/m
|
||||
public synthetic fun getUser ()Lnet/mamoe/mirai/contact/User;
|
||||
}
|
||||
|
||||
public final class net/mamoe/mirai/event/events/FriendInputStatusChangedEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/FriendEvent, net/mamoe/mirai/internal/network/Packet {
|
||||
public final class net/mamoe/mirai/event/events/FriendInputStatusChangedEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/FriendEvent, net/mamoe/mirai/internal/event/VerboseEvent, net/mamoe/mirai/internal/network/Packet {
|
||||
public final fun component1 ()Lnet/mamoe/mirai/contact/Friend;
|
||||
public final fun component2 ()Z
|
||||
public final fun copy (Lnet/mamoe/mirai/contact/Friend;Z)Lnet/mamoe/mirai/event/events/FriendInputStatusChangedEvent;
|
||||
@ -2537,7 +2537,7 @@ public final class net/mamoe/mirai/event/events/GroupTempMessageSyncEvent : net/
|
||||
public fun getTime ()I
|
||||
}
|
||||
|
||||
public abstract class net/mamoe/mirai/event/events/ImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public abstract class net/mamoe/mirai/event/events/ImageUploadEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public abstract fun getSource ()Lnet/mamoe/mirai/utils/ExternalResource;
|
||||
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||
@ -2801,7 +2801,7 @@ public abstract interface class net/mamoe/mirai/event/events/MessageEvent : net/
|
||||
public abstract fun getTime ()I
|
||||
}
|
||||
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePostSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePostSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public final fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public abstract fun getException ()Ljava/lang/Throwable;
|
||||
public abstract fun getMessage ()Lnet/mamoe/mirai/message/data/MessageChain;
|
||||
@ -2809,7 +2809,7 @@ public abstract class net/mamoe/mirai/event/events/MessagePostSendEvent : net/ma
|
||||
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||
}
|
||||
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePreSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent {
|
||||
public abstract class net/mamoe/mirai/event/events/MessagePreSendEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/CancellableEvent, net/mamoe/mirai/event/events/BotActiveEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/event/VerboseEvent {
|
||||
public final fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public abstract fun getMessage ()Lnet/mamoe/mirai/message/data/Message;
|
||||
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
|
||||
@ -5440,6 +5440,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
|
||||
public final fun getWorkingDir ()Ljava/io/File;
|
||||
public final synthetic fun inheritCoroutineContext (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun isConvertLineSeparator ()Z
|
||||
public final fun isShowingVerboseEventLog ()Z
|
||||
public final fun loadDeviceInfoJson (Ljava/lang/String;)V
|
||||
public final fun noBotLog ()V
|
||||
public final fun noNetworkLog ()V
|
||||
@ -5481,6 +5482,7 @@ public class net/mamoe/mirai/utils/BotConfiguration {
|
||||
public final fun setProtocol (Lnet/mamoe/mirai/utils/BotConfiguration$MiraiProtocol;)V
|
||||
public final fun setReconnectPeriodMillis (J)V
|
||||
public final fun setReconnectionRetryTimes (I)V
|
||||
public final fun setShowingVerboseEventLog (Z)V
|
||||
public final fun setStatHeartbeatPeriodMillis (J)V
|
||||
public final fun setWorkingDir (Ljava/io/File;)V
|
||||
}
|
||||
|
@ -17,12 +17,11 @@ import kotlinx.coroutines.sync.withLock
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.event.events.BotEvent
|
||||
import net.mamoe.mirai.event.events.MessageEvent
|
||||
import net.mamoe.mirai.internal.event.VerboseEvent
|
||||
import net.mamoe.mirai.internal.event.callAndRemoveIfRequired
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.verbose
|
||||
|
||||
/**
|
||||
* 可被监听的类, 可以是任何 class 或 object.
|
||||
@ -156,6 +155,8 @@ internal open class _EventBroadcast {
|
||||
@Volatile
|
||||
@JvmStatic
|
||||
var implementation: _EventBroadcast = _EventBroadcast()
|
||||
|
||||
private val SHOW_VERBOSE_EVENT_ALWAYS = systemProp("mirai.event.show.verbose.events", false)
|
||||
}
|
||||
|
||||
open suspend fun <E : Event> broadcastPublic(event: E): E = event.apply { Mirai.broadcastEvent(this) }
|
||||
@ -177,11 +178,23 @@ internal open class _EventBroadcast {
|
||||
return event
|
||||
}
|
||||
|
||||
private fun isVerboseEvent(event: Event): Boolean {
|
||||
if (SHOW_VERBOSE_EVENT_ALWAYS) return false
|
||||
if (event is VerboseEvent) {
|
||||
if (event is BotEvent) {
|
||||
return !event.bot.configuration.isShowingVerboseEventLog
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun logEvent(event: Event) {
|
||||
if (event is Packet.NoEventLog) return
|
||||
if (event is Packet.NoLog) return
|
||||
if (event is MessageEvent) return // specially handled in [LoggingPacketHandlerAdapter]
|
||||
// if (this is Packet) return@withLock // all [Packet]s are logged in [LoggingPacketHandlerAdapter]
|
||||
if (isVerboseEvent(event)) return
|
||||
|
||||
if (event is BotEvent) {
|
||||
event.bot.logger.verbose { "Event: $event" }
|
||||
|
@ -19,6 +19,7 @@ import net.mamoe.mirai.event.AbstractEvent
|
||||
import net.mamoe.mirai.event.CancellableEvent
|
||||
import net.mamoe.mirai.event.events.ImageUploadEvent.Failed
|
||||
import net.mamoe.mirai.event.events.ImageUploadEvent.Succeed
|
||||
import net.mamoe.mirai.internal.event.VerboseEvent
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.utils.ExternalResource
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
@ -35,7 +36,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
public data class BeforeImageUploadEvent @MiraiInternalApi constructor(
|
||||
public val target: Contact,
|
||||
public val source: ExternalResource
|
||||
) : BotEvent, BotActiveEvent, AbstractEvent(), CancellableEvent {
|
||||
) : BotEvent, BotActiveEvent, AbstractEvent(), CancellableEvent, VerboseEvent {
|
||||
public override val bot: Bot
|
||||
get() = target.bot
|
||||
}
|
||||
@ -51,7 +52,7 @@ public data class BeforeImageUploadEvent @MiraiInternalApi constructor(
|
||||
* @see Succeed
|
||||
* @see Failed
|
||||
*/
|
||||
public sealed class ImageUploadEvent : BotEvent, BotActiveEvent, AbstractEvent() {
|
||||
public sealed class ImageUploadEvent : BotEvent, BotActiveEvent, AbstractEvent(), VerboseEvent {
|
||||
public abstract val target: Contact
|
||||
public abstract val source: ExternalResource
|
||||
public override val bot: Bot
|
||||
|
@ -16,6 +16,7 @@ import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.event.AbstractEvent
|
||||
import net.mamoe.mirai.event.CancellableEvent
|
||||
import net.mamoe.mirai.internal.event.VerboseEvent
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.MessageChain
|
||||
import net.mamoe.mirai.message.data.MessageSource
|
||||
@ -32,7 +33,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
* @see Contact.sendMessage 发送消息. 为广播这个事件的唯一途径
|
||||
* @see MessagePreSendEvent
|
||||
*/
|
||||
public sealed class MessagePostSendEvent<C : Contact> : BotEvent, BotActiveEvent, AbstractEvent() {
|
||||
public sealed class MessagePostSendEvent<C : Contact> : BotEvent, BotActiveEvent, AbstractEvent(), VerboseEvent {
|
||||
/** 发信目标. */
|
||||
public abstract val target: C
|
||||
public final override val bot: Bot get() = target.bot
|
||||
|
@ -16,6 +16,7 @@ import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.event.AbstractEvent
|
||||
import net.mamoe.mirai.event.CancellableEvent
|
||||
import net.mamoe.mirai.internal.event.VerboseEvent
|
||||
import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
|
||||
@ -32,7 +33,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
*
|
||||
* @see Contact.sendMessage 发送消息. 为广播这个事件的唯一途径
|
||||
*/
|
||||
public sealed class MessagePreSendEvent : BotEvent, BotActiveEvent, AbstractEvent(), CancellableEvent {
|
||||
public sealed class MessagePreSendEvent : BotEvent, BotActiveEvent, AbstractEvent(), CancellableEvent, VerboseEvent {
|
||||
/** 发信目标. */
|
||||
public abstract val target: Contact
|
||||
public final override val bot: Bot get() = target.bot
|
||||
|
@ -20,6 +20,7 @@ import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.User
|
||||
import net.mamoe.mirai.event.AbstractEvent
|
||||
import net.mamoe.mirai.internal.event.VerboseEvent
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@ -118,4 +119,4 @@ public data class FriendInputStatusChangedEvent @MiraiInternalApi public constru
|
||||
public override val friend: Friend,
|
||||
public val inputting: Boolean,
|
||||
|
||||
) : FriendEvent, Packet, AbstractEvent()
|
||||
) : FriendEvent, Packet, AbstractEvent(), VerboseEvent
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.event
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
|
||||
/**
|
||||
* 标记一个事件过于冗长, 默认不显示
|
||||
*/
|
||||
@MiraiInternalApi
|
||||
public interface VerboseEvent // May be public?
|
@ -429,6 +429,15 @@ public open class BotConfiguration { // open for Java
|
||||
botLoggerSupplier = { _ -> SilentLogger }
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示过于冗长的事件日志
|
||||
*
|
||||
* 默认为 `false`
|
||||
*
|
||||
* @since 2.8
|
||||
*/
|
||||
public var isShowingVerboseEventLog: Boolean = false
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Cache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -569,6 +578,7 @@ public open class BotConfiguration { // open for Java
|
||||
new.cacheDir = cacheDir
|
||||
new.contactListCache = contactListCache
|
||||
new.convertLineSeparator = convertLineSeparator
|
||||
new.isShowingVerboseEventLog = isShowingVerboseEventLog
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user