Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7662ab4e08 | ||
|
8c2b78e30b | ||
|
6002e20080 |
29
logger.go
29
logger.go
@ -22,22 +22,17 @@ type Logger interface {
|
||||
|
||||
type logger struct{}
|
||||
|
||||
func (l *logger) Trace(args ...interface{})
|
||||
func (l *logger) Tracef(format string, args ...interface{})
|
||||
|
||||
func (l *logger) Debug(args ...interface{})
|
||||
func (l *logger) Debugf(format string, args ...interface{})
|
||||
|
||||
func (l *logger) Info(args ...interface{})
|
||||
func (l *logger) Infof(format string, args ...interface{})
|
||||
|
||||
func (l *logger) Error(args ...interface{})
|
||||
func (l *logger) Errorf(format string, args ...interface{})
|
||||
|
||||
func (l *logger) Fatal(args ...interface{})
|
||||
func (l *logger) Fatalf(format string, args ...interface{})
|
||||
|
||||
func (l *logger) Panic(args ...interface{})
|
||||
func (l *logger) Panicf(format string, args ...interface{})
|
||||
func (l *logger) Trace(args ...interface{}) {}
|
||||
func (l *logger) Tracef(format string, args ...interface{}) {}
|
||||
func (l *logger) Debug(args ...interface{}) {}
|
||||
func (l *logger) Debugf(format string, args ...interface{}) {}
|
||||
func (l *logger) Info(args ...interface{}) {}
|
||||
func (l *logger) Infof(format string, args ...interface{}) {}
|
||||
func (l *logger) Error(args ...interface{}) {}
|
||||
func (l *logger) Errorf(format string, args ...interface{}) {}
|
||||
func (l *logger) Fatal(args ...interface{}) {}
|
||||
func (l *logger) Fatalf(format string, args ...interface{}) {}
|
||||
func (l *logger) Panic(args ...interface{}) {}
|
||||
func (l *logger) Panicf(format string, args ...interface{}) {}
|
||||
|
||||
var DefaultLogger = &logger{}
|
||||
|
@ -25,6 +25,7 @@ func NewManager(tun io.ReadWriter) *Manager {
|
||||
accept: make(chan *DataFrame, 1024),
|
||||
newConnection: make(chan *Connection),
|
||||
delConnection: make(chan *Connection),
|
||||
closed: make(chan bool),
|
||||
logger: DefaultLogger,
|
||||
}
|
||||
}
|
||||
@ -47,9 +48,11 @@ func (m *Manager) Run() {
|
||||
m.Connections[connection.ID] = connection
|
||||
m.logger.Tracef("connection '%s' registered", connection.ID)
|
||||
case connection := <-m.delConnection:
|
||||
if !connection.closed {
|
||||
connection.Close()
|
||||
delete(m.Connections, connection.ID)
|
||||
m.logger.Tracef("connection '%s' unregistered", connection.ID)
|
||||
}
|
||||
case onReceiveQueue <- true:
|
||||
go m.onReceive(onReceiveQueue)
|
||||
}
|
||||
|
Reference in New Issue
Block a user