1
0
Fork 0
forked from External/ergo

move to channel-based logging

This commit is contained in:
Jeremy Latt 2014-03-08 15:01:15 -08:00
parent 77d053ccac
commit e15f47c766
9 changed files with 80 additions and 71 deletions

View file

@ -3,7 +3,6 @@ package irc
import (
"bufio"
"io"
"log"
"net"
"strings"
)
@ -38,9 +37,7 @@ func (socket *Socket) String() string {
func (socket *Socket) Close() {
socket.conn.Close()
if DEBUG_NET {
log.Printf("%s closed", socket)
}
Log.debug.Printf("%s closed", socket)
}
func (socket *Socket) readLines(commands chan<- Command) {
@ -57,9 +54,7 @@ func (socket *Socket) readLines(commands chan<- Command) {
if len(line) == 0 {
continue
}
if DEBUG_NET {
log.Printf("%s → %s", socket, line)
}
Log.debug.Printf("%s → %s", socket, line)
msg, err := ParseCommand(line)
if err != nil {
@ -87,16 +82,14 @@ func (socket *Socket) Write(line string) (err error) {
return
}
if DEBUG_NET {
log.Printf("%s ← %s", socket, line)
}
Log.debug.Printf("%s ← %s", socket, line)
return
}
func (socket *Socket) isError(err error, dir rune) bool {
if err != nil {
if DEBUG_NET && (err != io.EOF) {
log.Printf("%s %c error: %s", socket, dir, err)
if err != io.EOF {
Log.debug.Printf("%s %c error: %s", socket, dir, err)
}
return true
}