implement Client.String()

This commit is contained in:
Liam Stanley 2017-02-12 14:31:57 -05:00
parent aab3f30549
commit 383e1300bb
2 changed files with 14 additions and 1 deletions

View File

@ -187,6 +187,19 @@ func New(config Config) *Client {
return c
}
// String returns a brief description of the current client state.
func (c *Client) String() string {
var connected bool
if c.conn != nil {
connected = c.conn.connected
}
return fmt.Sprintf(
"<Client init:%q handlers:%s connected:%t reconnecting:%t tries:%d>",
c.initTime.String(), c.Handlers.Len(), connected, c.reconnecting, c.tries,
)
}
// Connect attempts to connect to the given IRC server
func (c *Client) Connect() error {
// Clean up any old running stuff.

View File

@ -120,7 +120,7 @@ func (c *Caller) String() string {
}
c.mu.RUnlock()
return fmt.Sprintf("<Caller() external:%d internal:%d>", c.Len(), total)
return fmt.Sprintf("<Caller external:%d internal:%d>", c.Len(), total)
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"