1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-07-01 02:53:53 +00:00

Switch to using and propagating logger.

This commit is contained in:
Alex Bramley 2011-10-22 23:57:22 +01:00
parent 88a664833e
commit 1fbd0a8b17
3 changed files with 42 additions and 24 deletions

View file

@ -11,6 +11,7 @@ type Nick struct {
Modes *NickMode
lookup map[string]*Channel
chans map[*Channel]*ChanPrivs
l logging.Logger
}
// A struct representing the modes of an IRC Nick (User Modes)
@ -43,12 +44,13 @@ func init() {
* Nick methods for state management
\******************************************************************************/
func NewNick(n string) *Nick {
func NewNick(n string, l logging.Logger) *Nick {
return &Nick{
Nick: n,
Modes: new(NickMode),
chans: make(map[*Channel]*ChanPrivs),
lookup: make(map[string]*Channel),
l: l,
}
}
@ -68,6 +70,8 @@ func (nk *Nick) addChannel(ch *Channel, cp *ChanPrivs) {
if _, ok := nk.chans[ch]; !ok {
nk.chans[ch] = cp
nk.lookup[ch.Name] = ch
} else {
nk.l.Warn("Nick.addChannel(): %s already on %s.", nk.Nick, ch.Name)
}
}
@ -76,6 +80,8 @@ func (nk *Nick) delChannel(ch *Channel) {
if _, ok := nk.chans[ch]; ok {
nk.chans[ch] = nil, false
nk.lookup[ch.Name] = nil, false
} else {
nk.l.Warn("Nick.delChannel(): %s not on %s.", nk.Nick, ch.Name)
}
}
@ -99,7 +105,7 @@ func (nk *Nick) ParseModes(modes string) {
case 'z':
nk.Modes.SSL = modeop
default:
logging.Info("Nick.ParseModes(): unknown mode char %c", m)
nk.l.Info("Nick.ParseModes(): unknown mode char %c", m)
}
}
}