Skip to content

v1.4.0

Latest
Compare
Choose a tag to compare
@nekomeowww nekomeowww released this 29 Aug 10:47
v1.4.0
2a9cdf2
  • feat: new WithZapLoggerFuncHandler for zap logger

Quite useful with zap logger when working with loads of different omitting error handling use cases:

may := fo.NewMay()
may.Use(fo.WithZapLoggerHandler(zapLogger))

may.Invoke(os.Open("./test_file.json"), "failed to open file", zap.String("file", "test_file.json"))

or having this pattern in https://github.com/nekomeowww/insights-bot/blob/967fa028caf356b0a96eaf19d85dcaa2968bbd1f/internal/services/autorecap/autorecap.go#L462-L465

func handleMessage() {
	may.Invoke(m.botService.UnpinChatMessage(tgbot.NewUnpinChatMessageConfig(chatID, lastPinnedMessage.MessageID)), "failed to unpin chat message", zap.Int64("chat_id", chatID), zap.Int("message_id", lastPinnedMessage.MessageID))
	may.Invoke(m.chathistories.UpdatePinnedMessage(lastPinnedMessage.ChatID, lastPinnedMessage.MessageID, false), "failed to save one telegram sent message", zap.Int64("chat_id", lastPinnedMessage.ChatID), zap.Int("message_id", lastPinnedMessage.MessageID))
	may.Invoke(m.botService.PinChatMessage(tgbot.NewPinChatMessageConfig(chatID, sentMsg.MessageID)), "failed to pin chat message", zap.Int64("chat_id", chatID), zap.Int("message_id", sentMsg.MessageID))
	may.Invoke(m.chathistories.SaveOneTelegramSentMessage(&sentMsg, true), "failed to save one telegram sent message")
}

Full Changelog: v1.3.0...v1.4.0