mirror of https://github.com/fluffle/goirc
Added timestamps to irc.Line and debug output
This commit is contained in:
parent
83e1f9ca74
commit
8ad6e67467
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue