mirror of
https://github.com/woodchen-ink/Q58Bot.git
synced 2025-07-18 05:42:06 +08:00
优化错误日志记录和链接过滤日志输出
在Binance服务中,增强错误日志记录,提供更详细的上下文信息,包括完整的消息内容和聊天ID,以便更快地诊断问题。 在链接过滤服务中,实现更清晰的日志输出,突出显示新发现的非白名单链接,并直接在检查和过滤过程中记录,提高可读性和效率。
This commit is contained in:
parent
cef184fcc0
commit
5f63a202b4
@ -101,7 +101,7 @@ func sendPriceUpdate() {
|
||||
msg.ParseMode = "Markdown"
|
||||
sentMsg, err := bot.Send(msg)
|
||||
if err != nil {
|
||||
log.Printf("Failed to send message: %v", err)
|
||||
log.Printf("Failed to send message. Error: %v\nFull message content:\nChat ID: %d\nMessage: %s", err, chatID, message)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -186,14 +186,17 @@ func processLinks(links []string, linkFilter *LinkFilter) (bool, []string) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(newNonWhitelistedLinks) > 0 {
|
||||
logger.Printf("发现新的非白名单链接: %v", newNonWhitelistedLinks)
|
||||
}
|
||||
return false, newNonWhitelistedLinks
|
||||
}
|
||||
func (lf *LinkFilter) CheckAndFilterLink(bot *tgbotapi.BotAPI, message *tgbotapi.Message) bool {
|
||||
// 判断消息是否应当被过滤及找出新的非白名单链接
|
||||
shouldFilter, newLinks := ShouldFilter(message.Text, lf)
|
||||
|
||||
// 如果发现新的非白名单链接,记录日志
|
||||
if len(newLinks) > 0 {
|
||||
logger.Printf("发现新的非白名单链接: %v", newLinks)
|
||||
}
|
||||
|
||||
if shouldFilter {
|
||||
// 记录被过滤的消息
|
||||
logger.Printf("消息应该被过滤: %s", message.Text)
|
||||
@ -218,11 +221,5 @@ func (lf *LinkFilter) CheckAndFilterLink(bot *tgbotapi.BotAPI, message *tgbotapi
|
||||
return true
|
||||
}
|
||||
|
||||
// 如果发现新的非白名单链接
|
||||
if len(newLinks) > 0 {
|
||||
// 记录新的非白名单链接
|
||||
logger.Printf("发现新的非白名单链接: %v", newLinks)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user