From 66f4a5906c387da5368bdeee52b7871f31347edb Mon Sep 17 00:00:00 2001 From: Vegard Berg Date: Tue, 20 Aug 2024 22:57:28 +0200 Subject: [PATCH] feature: Log time used to fetch GuildSettings. --- model/guild_settings.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/model/guild_settings.go b/model/guild_settings.go index 506710a..d52e2d5 100644 --- a/model/guild_settings.go +++ b/model/guild_settings.go @@ -1,6 +1,7 @@ package model import ( + "log/slog" "time" "github.com/disgoorg/snowflake/v2" @@ -33,11 +34,18 @@ type GuildSettings struct { } func GetGuildSettings(guildID snowflake.ID) (*GuildSettings, error) { + cur := time.Now() settings := GuildSettings{GuildID: guildID} res := DB.FirstOrCreate(&settings, "guild_id = ?", guildID) if res.Error != nil { return nil, res.Error } + dur := time.Since(cur) + if dur > time.Second { + slog.Warn("GetGuildSettings took too long", "guild_id", guildID, "dur", dur) + } else { + slog.Debug("GetGuildSettings", "guild_id", guildID, "dur", dur) + } return &settings, nil }