From 066134263e4f2ba09df48c60721f0cc9ceba17c3 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 4 Oct 2014 08:10:14 -0400 Subject: [PATCH 1/3] Change duplicate error message for missing irc.nick. --- irc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/irc.go b/irc.go index 59c5372..1ee1405 100644 --- a/irc.go +++ b/irc.go @@ -341,7 +341,7 @@ func (irc *Connection) Connect(server string) error { return errors.New("'Log' points to nil") } if len(irc.nick) == 0 { - return errors.New("empty 'user'") + return errors.New("empty 'nick'") } if len(irc.user) == 0 { return errors.New("empty 'user'") From f997fc841af44d45f3d7037e20abddd436618315 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 4 Oct 2014 08:20:58 -0400 Subject: [PATCH 2/3] Add a 'VerboseReadLoop' option. Troubleshooting responses from the IRC server becomes easier when you can actually see the raw responses. This change adds a 'VerboseReadLoop' member to the Connection struct. When set to true, the raw messages sent from the server will be placed into the standard log for review. This message is printed before evaluating any callbacks. --- irc.go | 3 +++ irc_struct.go | 1 + 2 files changed, 4 insertions(+) diff --git a/irc.go b/irc.go index 1ee1405..2aa6c40 100644 --- a/irc.go +++ b/irc.go @@ -97,6 +97,9 @@ func (irc *Connection) readLoop() { } /* XXX: len(args) == 0: args should be empty */ + if irc.VerboseReadLoop { + irc.Log.Println(event.Raw) + } irc.RunCallbacks(event) } diff --git a/irc_struct.go b/irc_struct.go index 161c6a2..6f7a259 100644 --- a/irc_struct.go +++ b/irc_struct.go @@ -38,6 +38,7 @@ type Connection struct { lastMessage time.Time VerboseCallbackHandler bool + VerboseReadLoop bool Log *log.Logger stopped bool From 80f67f76b5d864f383494565ed2bd615a2df2b4d Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sun, 5 Oct 2014 08:56:52 -0400 Subject: [PATCH 3/3] Add ReadLoop() debugging via Connection.Debug. --- irc.go | 10 +++++----- irc_struct.go | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/irc.go b/irc.go index 2aa6c40..3e5b717 100644 --- a/irc.go +++ b/irc.go @@ -69,6 +69,10 @@ func (irc *Connection) readLoop() { break } + if irc.Debug { + irc.Log.Printf("<-- %s\n", strings.TrimSpace(msg)) + } + irc.lastMessage = time.Now() msg = msg[:len(msg)-2] //Remove \r\n event := &Event{Raw: msg} @@ -97,10 +101,6 @@ func (irc *Connection) readLoop() { } /* XXX: len(args) == 0: args should be empty */ - if irc.VerboseReadLoop { - irc.Log.Println(event.Raw) - } - irc.RunCallbacks(event) } } @@ -122,7 +122,7 @@ func (irc *Connection) writeLoop() { } if irc.Debug { - irc.Log.Printf("--> %s\n", b) + irc.Log.Printf("--> %s\n", strings.TrimSpace(b)) } // Set a write deadline based on the time out diff --git a/irc_struct.go b/irc_struct.go index 6f7a259..161c6a2 100644 --- a/irc_struct.go +++ b/irc_struct.go @@ -38,7 +38,6 @@ type Connection struct { lastMessage time.Time VerboseCallbackHandler bool - VerboseReadLoop bool Log *log.Logger stopped bool