Skip to content

Commit 69fb9e1

Browse files
authored
Make it easier to distinguish between Read and Write in the DebugCallback (#31)
1 parent 1d9a347 commit 69fb9e1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

conn.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Conn struct {
1212
// DebugCallback is a callback for every line of input and
1313
// output. It is meant for debugging and is not guaranteed to
1414
// be stable.
15-
DebugCallback func(line string)
15+
DebugCallback func(operation, line string)
1616

1717
// Internal things
1818
conn io.ReadWriteCloser
@@ -23,7 +23,7 @@ type Conn struct {
2323
func NewConn(rwc io.ReadWriteCloser) *Conn {
2424
// Create the client
2525
c := &Conn{
26-
func(line string) {},
26+
func(operation, line string) {},
2727
rwc,
2828
bufio.NewReader(rwc),
2929
}
@@ -34,7 +34,7 @@ func NewConn(rwc io.ReadWriteCloser) *Conn {
3434
// Write is a simple function which will write the given line to the
3535
// underlying connection.
3636
func (c *Conn) Write(line string) {
37-
c.DebugCallback("--> " + line)
37+
c.DebugCallback("write", line)
3838
c.conn.Write([]byte(line))
3939
c.conn.Write([]byte("\r\n"))
4040
}
@@ -58,7 +58,7 @@ func (c *Conn) ReadMessage() (*Message, error) {
5858
return nil, err
5959
}
6060

61-
c.DebugCallback("<-- " + strings.TrimRight(line, "\r\n"))
61+
c.DebugCallback("read", strings.TrimRight(line, "\r\n"))
6262

6363
// Parse the message from our line
6464
m := ParseMessage(line)

0 commit comments

Comments
 (0)