From b7538d9b936ee667eb152c519be8560699b5b590 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 31 Mar 2021 23:16:23 +0200 Subject: [PATCH] Fix: Log channel in debug / trace messages Signed-off-by: Knut Ahlers --- irc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/irc.go b/irc.go index f43edb2..368f7d1 100644 --- a/irc.go +++ b/irc.go @@ -116,6 +116,13 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) { func (i ircHandler) Run() error { return errors.Wrap(i.c.Run(), "running IRC client") } +func (ircHandler) getChannel(m *irc.Message) string { + if len(m.Params) > 0 { + return m.Params[0] + } + return "" +} + func (i ircHandler) handleJoin(m *irc.Message) { go handleMessage(i.c, m, eventTypeJoin) } @@ -142,6 +149,7 @@ func (i ircHandler) handlePermit(m *irc.Message) { func (i ircHandler) handleTwitchNotice(m *irc.Message) { log.WithFields(log.Fields{ + "channel": i.getChannel(m), "tags": m.Tags, "trailing": m.Trailing, }).Debug("IRC NOTICE event") @@ -161,6 +169,7 @@ func (i ircHandler) handleTwitchNotice(m *irc.Message) { func (i ircHandler) handleTwitchPrivmsg(m *irc.Message) { log.WithFields(log.Fields{ + "channel": i.getChannel(m), "name": m.Name, "user": m.User, "tags": m.Tags, @@ -186,6 +195,7 @@ func (i ircHandler) handleTwitchPrivmsg(m *irc.Message) { func (i ircHandler) handleTwitchUsernotice(m *irc.Message) { log.WithFields(log.Fields{ + "channel": i.getChannel(m), "tags": m.Tags, "trailing": m.Trailing, }).Debug("IRC USERNOTICE event")