new logging

This commit is contained in:
Anton Kaliaev
2017-04-28 00:37:18 +04:00
parent 8d8e35ae53
commit 986bdd00a5
20 changed files with 141 additions and 102 deletions

View File

@ -94,15 +94,15 @@ func (s *SocketServer) acceptConnectionsRoutine() {
// semaphore <- struct{}{}
// Accept a connection
log.Notice("Waiting for new connection...")
s.Logger.Info("Waiting for new connection...")
conn, err := s.listener.Accept()
if err != nil {
if !s.IsRunning() {
return // Ignore error from listener closing.
}
log.Crit("Failed to accept connection: " + err.Error())
s.Logger.Error("Failed to accept connection: " + err.Error())
} else {
log.Notice("Accepted a new connection")
s.Logger.Info("Accepted a new connection")
}
connID := s.addConn(conn)
@ -119,18 +119,18 @@ func (s *SocketServer) acceptConnectionsRoutine() {
// Wait until signal to close connection
errClose := <-closeConn
if err == io.EOF {
log.Warn("Connection was closed by client")
s.Logger.Error("Connection was closed by client")
} else if errClose != nil {
log.Warn("Connection error", "error", errClose)
s.Logger.Error("Connection error", "error", errClose)
} else {
// never happens
log.Warn("Connection was closed.")
s.Logger.Error("Connection was closed.")
}
// Close the connection
err := s.rmConn(connID, conn)
if err != nil {
log.Warn("Error in closing connection", "error", err)
s.Logger.Error("Error in closing connection", "error", err)
}
// <-semaphore