mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
pre-commit: update and ban Msgf on zerolog logs
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
parent
40927f4b12
commit
7c227e175d
4 changed files with 17 additions and 12 deletions
|
|
@ -22,7 +22,8 @@ repos:
|
|||
#- id: go-staticcheck-repo-mod
|
||||
|
||||
- repo: https://github.com/beeper/pre-commit-go
|
||||
rev: v0.4.1
|
||||
rev: v0.4.2
|
||||
hooks:
|
||||
- id: prevent-literal-http-methods
|
||||
- id: zerolog-ban-global-log
|
||||
- id: zerolog-ban-msgf
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func (ce *Event) ReplyAdvanced(msg string, allowMarkdown, allowHTML bool) {
|
|||
content.MsgType = event.MsgNotice
|
||||
_, err := ce.MainIntent().SendMessageEvent(ce.Ctx, ce.RoomID, event.EventMessage, content)
|
||||
if err != nil {
|
||||
ce.ZLog.Error().Err(err).Msgf("Failed to reply to command")
|
||||
ce.ZLog.Error().Err(err).Msg("Failed to reply to command")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ func (ce *Event) ReplyAdvanced(msg string, allowMarkdown, allowHTML bool) {
|
|||
func (ce *Event) React(key string) {
|
||||
_, err := ce.MainIntent().SendReaction(ce.Ctx, ce.RoomID, ce.EventID, key)
|
||||
if err != nil {
|
||||
ce.ZLog.Error().Err(err).Msgf("Failed to react to command")
|
||||
ce.ZLog.Error().Err(err).Msg("Failed to react to command")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ func (ce *Event) React(key string) {
|
|||
func (ce *Event) Redact(req ...mautrix.ReqRedact) {
|
||||
_, err := ce.MainIntent().RedactEvent(ce.Ctx, ce.RoomID, ce.EventID, req...)
|
||||
if err != nil {
|
||||
ce.ZLog.Error().Err(err).Msgf("Failed to redact command")
|
||||
ce.ZLog.Error().Err(err).Msg("Failed to redact command")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +90,6 @@ func (ce *Event) Redact(req ...mautrix.ReqRedact) {
|
|||
func (ce *Event) MarkRead() {
|
||||
err := ce.MainIntent().SendReceipt(ce.Ctx, ce.RoomID, ce.EventID, event.ReceiptTypeRead, nil)
|
||||
if err != nil {
|
||||
ce.ZLog.Error().Err(err).Msgf("Failed to mark command as read")
|
||||
ce.ZLog.Error().Err(err).Msg("Failed to mark command as read")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func (ce *Event) ReplyAdvanced(msg string, allowMarkdown, allowHTML bool) {
|
|||
content.MsgType = event.MsgNotice
|
||||
_, err := ce.Bot.SendMessage(ce.Ctx, ce.OrigRoomID, event.EventMessage, &event.Content{Parsed: &content}, nil)
|
||||
if err != nil {
|
||||
ce.Log.Err(err).Msgf("Failed to reply to command")
|
||||
ce.Log.Err(err).Msg("Failed to reply to command")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ func (ce *Event) React(key string) {
|
|||
},
|
||||
}, nil)
|
||||
if err != nil {
|
||||
ce.Log.Err(err).Msgf("Failed to react to command")
|
||||
ce.Log.Err(err).Msg("Failed to react to command")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ func (ce *Event) Redact(req ...mautrix.ReqRedact) {
|
|||
},
|
||||
}, nil)
|
||||
if err != nil {
|
||||
ce.Log.Err(err).Msgf("Failed to redact command")
|
||||
ce.Log.Err(err).Msg("Failed to redact command")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +95,6 @@ func (ce *Event) MarkRead() {
|
|||
// TODO
|
||||
//err := ce.Bot.SendReceipt(ce.Ctx, ce.RoomID, ce.EventID, event.ReceiptTypeRead, nil)
|
||||
//if err != nil {
|
||||
// ce.Log.Err(err).Msgf("Failed to mark command as read")
|
||||
// ce.Log.Err(err).Msg("Failed to mark command as read")
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,15 @@ func (mach *OlmMachine) RequestRoomKey(ctx context.Context, toUser id.UserID, to
|
|||
select {
|
||||
case <-keyResponseReceived:
|
||||
// key request successful
|
||||
mach.Log.Debug().Msgf("Key for session %v was received, cancelling other key requests", sessionID)
|
||||
mach.Log.Debug().
|
||||
Stringer("session_id", sessionID).
|
||||
Msg("Key for session was received, cancelling other key requests")
|
||||
resChan <- true
|
||||
case <-ctx.Done():
|
||||
// if the context is done, key request was unsuccessful
|
||||
mach.Log.Debug().Msgf("Context closed (%v) before forwared key for session %v received, sending key request cancellation", ctx.Err(), sessionID)
|
||||
mach.Log.Debug().Err(err).
|
||||
Stringer("session_id", sessionID).
|
||||
Msg("Context closed before forwarded key for session received, sending key request cancellation")
|
||||
resChan <- false
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +336,7 @@ func (mach *OlmMachine) HandleRoomKeyRequest(ctx context.Context, sender id.User
|
|||
}
|
||||
if internalID := igs.ID(); internalID != content.Body.SessionID {
|
||||
// Should this be an error?
|
||||
log = log.With().Str("unexpected_session_id", internalID.String()).Logger()
|
||||
log = log.With().Stringer("unexpected_session_id", internalID).Logger()
|
||||
}
|
||||
|
||||
firstKnownIndex := igs.Internal.FirstKnownIndex()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue