Example #1
0
// watch watches the connection for error, sends detected error to c.errors
func (c *conn) watch(log *loggo.Logger) {
	for {
		data := make([]byte, 1)
		_, err := c.netConn.Read(data)

		if err != nil {
			log.Errorf("Connection error: %v on Connection: %d", err, c.connectionId)
			c.netConn.Close()
			c.errors <- err
			return
		}
	}
}
Example #2
0
// reconnectNeeded determines if a reconnect is needed by checking for a
// message on the readErrors channel
func (c *conn) reconnectNeeded(log *loggo.Logger) bool {
	if c == nil {
		return true
	}

	if c.forceReset {
		return true
	}

	select {
	case <-c.errors:
		log.Errorf("Error from connection: %d reconnectNeeded due to error while reading", c.connectionId)
		return true
	default:
		return false
	}
}
Example #3
0
func (*loggerSuite) TestRootLogger(c *gc.C) {
	root := loggo.Logger{}
	c.Assert(root.Name(), gc.Equals, "<root>")
	c.Assert(root.IsErrorEnabled(), gc.Equals, true)
	c.Assert(root.IsWarningEnabled(), gc.Equals, true)
	c.Assert(root.IsInfoEnabled(), gc.Equals, false)
	c.Assert(root.IsDebugEnabled(), gc.Equals, false)
	c.Assert(root.IsTraceEnabled(), gc.Equals, false)
}