Skip to content

Commit 7a5765f

Browse files
authored
Merge pull request #642 from ackleymi/add-log
Adds log to readLoop just like writeLoop
2 parents 2da4180 + 035d82e commit 7a5765f

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

acceptor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func (a *Acceptor) handleConnection(netConn net.Conn) {
356356

357357
go func() {
358358
msgIn <- fixIn{msgBytes, parser.lastRead}
359-
readLoop(parser, msgIn)
359+
readLoop(parser, msgIn, a.globalLog)
360360
}()
361361

362362
writeLoop(netConn, msgOut, a.globalLog)

connection.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ func writeLoop(connection io.Writer, messageOut chan []byte, log Log) {
3030
}
3131
}
3232

33-
func readLoop(parser *parser, msgIn chan fixIn) {
33+
func readLoop(parser *parser, msgIn chan fixIn, log Log) {
3434
defer close(msgIn)
3535

3636
for {
3737
msg, err := parser.ReadMessage()
3838
if err != nil {
39+
log.OnEvent(err.Error())
3940
return
4041
}
4142
msgIn <- fixIn{msg, parser.lastRead}

connection_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestReadLoop(t *testing.T) {
4545
stream := "hello8=FIX.4.09=5blah10=103garbage8=FIX.4.09=4foo10=103"
4646

4747
parser := newParser(strings.NewReader(stream))
48-
go readLoop(parser, msgIn)
48+
go readLoop(parser, msgIn, nullLog{})
4949

5050
var tests = []struct {
5151
expectedMsg string

initiator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (i *Initiator) handleConnection(session *session, tlsConfig *tls.Config, di
198198
goto reconnect
199199
}
200200

201-
go readLoop(newParser(bufio.NewReader(netConn)), msgIn)
201+
go readLoop(newParser(bufio.NewReader(netConn)), msgIn, session.log)
202202
disconnected = make(chan interface{})
203203
go func() {
204204
writeLoop(netConn, msgOut, session.log)

0 commit comments

Comments
 (0)