From 9d1b4f07c8c5c58729bbdb41057fb3c15631ed6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 9 Oct 2022 03:14:53 +0200 Subject: [PATCH] Improve logging Log deleted and updated commands. --- main.go | 2 +- static_commands.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 7bbc5fc..6273f9c 100644 --- a/main.go +++ b/main.go @@ -63,7 +63,7 @@ func main() { } else if errors.Is(err, errTooShort) { bot.say(&message, "The command you entered is too short.") } else if err != nil { - logger.Errorf("channel %q command %v failed: %v", message.Channel, parsed, err) + logger.Errorf("Channel %q: Command %v failed: %v", message.Channel, parsed, err) } } }) diff --git a/static_commands.go b/static_commands.go index ed135f9..fb597a5 100644 --- a/static_commands.go +++ b/static_commands.go @@ -81,6 +81,7 @@ func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error } b.say(msg, "Success.") + b.logger.Infof("Channel %q: %q updated command %q", msg.Channel, msg.User.DisplayName, name) return nil } } @@ -110,6 +111,7 @@ func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error } b.say(msg, "Success.") + b.logger.Infof("Channel %q: %q deleted command %q", msg.Channel, msg.User.DisplayName, name) return nil } @@ -127,7 +129,7 @@ func (b *bot) lookupCommand(name string, msg *twitch.PrivateMessage) error { err := b.db.DB.QueryRow(query, msg.Channel, name).Scan(&response) if errors.Is(err, sql.ErrNoRows) { - b.logger.Infof("channel %q command %q not found", msg.Channel, name) + b.logger.Infof("Channel %q: Command %q not found", msg.Channel, name) return nil } else if err != nil { return err -- 2.44.0