From 8ad6e6746719bd5e8b1d2dc21203bddd5136240e Mon Sep 17 00:00:00 2001 From: Graham Lyon Date: Sat, 20 Nov 2010 23:40:45 +0000 Subject: [PATCH] Added timestamps to irc.Line and debug output --- client/connection.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/connection.go b/client/connection.go index 8cedfdf..a280de0 100644 --- a/client/connection.go +++ b/client/connection.go @@ -56,6 +56,7 @@ type Line struct { Nick, Ident, Host, Src string Cmd, Text, Raw string Args []string + Time *time.Time } // Creates a new IRC connection object, but doesn't connect to anything so @@ -187,7 +188,7 @@ func (conn *Conn) send() { } conn.io.Flush() if conn.Debug { - fmt.Println("-> " + line) + fmt.Println(time.UTC().Format("[15:04:05]") + " -> " + line) } } } @@ -196,6 +197,7 @@ func (conn *Conn) send() { func (conn *Conn) recv() { for { s, err := conn.io.ReadString('\n') + t := time.UTC() if err != nil { conn.error("irc.recv(): %s", err.String()) conn.shutdown() @@ -203,10 +205,10 @@ func (conn *Conn) recv() { } s = strings.Trim(s, "\r\n") if conn.Debug { - fmt.Println("<- " + s) + fmt.Println(t.Format("[15:04:05]") + " <- " + s) } - line := &Line{Raw: s} + line := &Line{Raw: s, Time: t} if s[0] == ':' { // remove a source and parse it if idx := strings.Index(s, " "); idx != -1 {