1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-07-07 14:00:33 +00:00

Remove golog

This commit is contained in:
Jakob Borg 2013-09-26 10:17:52 +02:00
parent 06a9cb5d0f
commit 2cbbdd6d7e
8 changed files with 3 additions and 124 deletions

View file

@ -5,8 +5,6 @@ import (
"crypto/tls"
"fmt"
"github.com/fluffle/goirc/state"
"github.com/fluffle/golog/logging"
"io"
"net"
"strings"
"sync"
@ -107,9 +105,8 @@ func SimpleClient(nick string, args ...string) *Conn {
}
func Client(cfg *Config) *Conn {
logging.InitFromFlags()
if cfg == nil || cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" {
logging.Fatal("irc.Client(): Both cfg.Nick and cfg.Ident must be non-empty.")
panic("irc.Client(): Both cfg.Nick and cfg.Ident must be non-empty.")
}
conn := &Conn{
cfg: cfg,
@ -196,7 +193,6 @@ func (conn *Conn) Connect() error {
if !hasPort(conn.cfg.Server) {
conn.cfg.Server += ":6697"
}
logging.Info("irc.Connect(): Connecting to %s with SSL.", conn.cfg.Server)
if s, err := tls.Dial("tcp", conn.cfg.Server, conn.cfg.SSLConfig); err == nil {
conn.sock = s
} else {
@ -206,7 +202,6 @@ func (conn *Conn) Connect() error {
if !hasPort(conn.cfg.Server) {
conn.cfg.Server += ":6667"
}
logging.Info("irc.Connect(): Connecting to %s without SSL.", conn.cfg.Server)
if s, err := net.Dial("tcp", conn.cfg.Server); err == nil {
conn.sock = s
} else {
@ -257,20 +252,14 @@ func (conn *Conn) recv() {
for {
s, err := conn.io.ReadString('\n')
if err != nil {
if err != io.EOF {
logging.Error("irc.recv(): %s", err.Error())
}
conn.shutdown()
return
}
s = strings.Trim(s, "\r\n")
logging.Debug("<- %s", s)
if line := parseLine(s); line != nil {
line.Time = time.Now()
conn.in <- line
} else {
logging.Warn("irc.recv(): problems parsing line:\n %s", s)
}
}
}
@ -309,23 +298,18 @@ func (conn *Conn) write(line string) {
if !conn.cfg.Flood {
if t := conn.rateLimit(len(line)); t != 0 {
// sleep for the current line's time value before sending it
logging.Debug("irc.rateLimit(): Flood! Sleeping for %.2f secs.",
t.Seconds())
<-time.After(t)
}
}
if _, err := conn.io.WriteString(line + "\r\n"); err != nil {
logging.Error("irc.send(): %s", err.Error())
conn.shutdown()
return
}
if err := conn.io.Flush(); err != nil {
logging.Error("irc.send(): %s", err.Error())
conn.shutdown()
return
}
logging.Debug("-> %s", line)
}
// Implement Hybrid's flood control algorithm to rate-limit outgoing lines.
@ -355,7 +339,6 @@ func (conn *Conn) shutdown() {
if !conn.connected {
return
}
logging.Info("irc.shutdown(): Disconnected from server.")
conn.dispatch(&Line{Cmd: DISCONNECTED})
conn.connected = false
conn.sock.Close()

View file

@ -3,7 +3,6 @@ package client
import (
"code.google.com/p/gomock/gomock"
"github.com/fluffle/goirc/state"
"github.com/fluffle/golog/logging"
"strings"
"testing"
"time"
@ -22,7 +21,6 @@ func setUp(t *testing.T, start ...bool) (*Conn, *testState) {
st := state.NewMockTracker(ctrl)
nc := MockNetConn(t)
c := SimpleClient("test", "test", "Testing IRC")
logging.SetLogLevel(logging.LogFatal)
c.st = st
c.sock = nc

View file

@ -1,7 +1,7 @@
package client
import (
"github.com/fluffle/golog/logging"
"log"
"runtime"
"strings"
"sync"
@ -92,7 +92,6 @@ func (hs *hSet) remove(hn *hNode) {
defer hs.Unlock()
l, ok := hs.set[hn.event]
if !ok {
logging.Error("Removing node for unknown event '%s'", hn.event)
return
}
if hn.next == nil {
@ -147,6 +146,6 @@ func (conn *Conn) dispatch(line *Line) {
func (conn *Conn) LogPanic(line *Line) {
if err := recover(); err != nil {
_, f, l, _ := runtime.Caller(2)
logging.Error("%s:%d: panic: %v", f, l, err)
log.Printf("%s:%d: panic: %v", f, l, err)
}
}

View file

@ -4,7 +4,6 @@ package client
// to manage tracking state for an IRC connection
import (
"github.com/fluffle/golog/logging"
"strings"
)
@ -51,8 +50,6 @@ func (conn *Conn) h_JOIN(line *Line) {
// first we've seen of this channel, so should be us joining it
// NOTE this will also take care of nk == nil && ch == nil
if nk != conn.cfg.Me {
logging.Warn("irc.JOIN(): JOIN to unknown channel %s received "+
"from (non-me) nick %s", line.Args[0], line.Nick)
return
}
ch = conn.st.NewChannel(line.Args[0])
@ -103,14 +100,9 @@ func (conn *Conn) h_MODE(line *Line) {
} else if nk := conn.st.GetNick(line.Args[0]); nk != nil {
// nick mode change, should be us
if nk != conn.cfg.Me {
logging.Warn("irc.MODE(): recieved MODE %s for (non-me) nick %s",
line.Args[1], line.Args[0])
return
}
nk.ParseModes(line.Args[1])
} else {
logging.Warn("irc.MODE(): not sure what to do with MODE %s",
strings.Join(line.Args, " "))
}
}
@ -118,9 +110,6 @@ func (conn *Conn) h_MODE(line *Line) {
func (conn *Conn) h_TOPIC(line *Line) {
if ch := conn.st.GetChannel(line.Args[0]); ch != nil {
ch.Topic = line.Args[1]
} else {
logging.Warn("irc.TOPIC(): topic change on unknown channel %s",
line.Args[0])
}
}
@ -130,9 +119,6 @@ func (conn *Conn) h_311(line *Line) {
nk.Ident = line.Args[2]
nk.Host = line.Args[3]
nk.Name = line.Args[5]
} else {
logging.Warn("irc.311(): received WHOIS info for unknown nick %s",
line.Args[1])
}
}
@ -140,9 +126,6 @@ func (conn *Conn) h_311(line *Line) {
func (conn *Conn) h_324(line *Line) {
if ch := conn.st.GetChannel(line.Args[1]); ch != nil {
ch.ParseModes(line.Args[2], line.Args[3:]...)
} else {
logging.Warn("irc.324(): received MODE settings for unknown channel %s",
line.Args[1])
}
}
@ -150,9 +133,6 @@ func (conn *Conn) h_324(line *Line) {
func (conn *Conn) h_332(line *Line) {
if ch := conn.st.GetChannel(line.Args[1]); ch != nil {
ch.Topic = line.Args[2]
} else {
logging.Warn("irc.332(): received TOPIC value for unknown channel %s",
line.Args[1])
}
}
@ -160,8 +140,6 @@ func (conn *Conn) h_332(line *Line) {
func (conn *Conn) h_352(line *Line) {
nk := conn.st.GetNick(line.Args[5])
if nk == nil {
logging.Warn("irc.352(): received WHO reply for unknown nick %s",
line.Args[5])
return
}
if nk == conn.Me() {
@ -220,9 +198,6 @@ func (conn *Conn) h_353(line *Line) {
}
}
}
} else {
logging.Warn("irc.353(): received NAMES list for unknown channel %s",
line.Args[2])
}
}
@ -230,8 +205,5 @@ func (conn *Conn) h_353(line *Line) {
func (conn *Conn) h_671(line *Line) {
if nk := conn.st.GetNick(line.Args[1]); nk != nil {
nk.Modes.SSL = true
} else {
logging.Warn("irc.671(): received WHOIS SSL info for unknown nick %s",
line.Args[1])
}
}