Skip to content

Commit

Permalink
pre-commit: ban Msgf() from zerolog
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <sumner@beeper.com>
  • Loading branch information
sumnerevans committed Dec 24, 2023
1 parent 8c8cfa8 commit f69c02a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude_types: [markdown]
Expand All @@ -13,3 +13,8 @@ repos:
hooks:
- id: go-imports-repo
- id: go-vet-repo-mod

- repo: https://github.com/beeper/pre-commit-go
rev: v0.2.2
hooks:
- id: zerolog-ban-msgf
4 changes: 2 additions & 2 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func discordToZeroLevel(level int) zerolog.Level {

func init() {
discordgo.Logger = func(msgL, caller int, format string, a ...interface{}) {
discordLog.WithLevel(discordToZeroLevel(msgL)).Caller(caller+1).Msgf(strings.TrimSpace(format), a...)
discordLog.WithLevel(discordToZeroLevel(msgL)).Caller(caller+1).Msgf(strings.TrimSpace(format), a...) // zerolog-allow-msgf
}
}

Expand Down Expand Up @@ -548,7 +548,7 @@ func (user *User) Connect() error {
}
userDiscordLog := user.log.With().Str("component", "discordgo").Logger()
session.Logger = func(msgL, caller int, format string, a ...interface{}) {
userDiscordLog.WithLevel(discordToZeroLevel(msgL)).Caller(caller+1).Msgf(strings.TrimSpace(format), a...)
userDiscordLog.WithLevel(discordToZeroLevel(msgL)).Caller(caller+1).Msgf(strings.TrimSpace(format), a...) // zerolog-allow-msgf
}
if !session.IsUser {
session.Identify.Intents = BotIntents
Expand Down

0 comments on commit f69c02a

Please sign in to comment.