From f69c02acb6e953e98c833be77a9d2692becad30f Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Sat, 23 Dec 2023 17:39:16 -0700 Subject: [PATCH] pre-commit: ban Msgf() from zerolog Signed-off-by: Sumner Evans --- .pre-commit-config.yaml | 7 ++++++- user.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ef386e..64a6eae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] @@ -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 diff --git a/user.go b/user.go index e2a29e4..174ed0d 100644 --- a/user.go +++ b/user.go @@ -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 } } @@ -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