diff --git a/proxy/log.go b/proxy/log.go new file mode 100644 index 00000000..45d31b87 --- /dev/null +++ b/proxy/log.go @@ -0,0 +1,7 @@ +package proxy + +import ( + "github.com/tendermint/go-logger" +) + +var log = logger.New("module", "proxy") diff --git a/proxy/remote_app_context.go b/proxy/remote_app_context.go index 09a7db5a..dd96abe7 100644 --- a/proxy/remote_app_context.go +++ b/proxy/remote_app_context.go @@ -21,7 +21,7 @@ const maxResponseSize = 1048576 // 1MB // with concurrent callers. type remoteAppContext struct { QuitService - sync.Mutex + sync.Mutex // [EB]: is this even used? reqQueue chan *reqRes @@ -65,7 +65,7 @@ func (app *remoteAppContext) SetResponseCallback(resCb Callback) { func (app *remoteAppContext) StopForError(err error) { app.mtx.Lock() - fmt.Println("Stopping remoteAppContext for error:", err) + log.Error("Stopping remoteAppContext for error.", "error", err) if app.err == nil { app.err = err } @@ -89,11 +89,15 @@ func (app *remoteAppContext) sendRequestsRoutine() { case <-app.QuitService.Quit: return case reqres := <-app.reqQueue: + + app.willSendReq(reqres) + wire.WriteBinary(reqres.Request, app.bufWriter, &n, &err) if err != nil { app.StopForError(err) return } + log.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request) if _, ok := reqres.Request.(tmsp.RequestFlush); ok { err = app.bufWriter.Flush() if err != nil { @@ -101,7 +105,6 @@ func (app *remoteAppContext) sendRequestsRoutine() { return } } - app.didSendReq(reqres) } } } @@ -121,6 +124,7 @@ func (app *remoteAppContext) recvResponseRoutine() { case tmsp.ResponseException: app.StopForError(errors.New(res.Error)) default: + log.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res) err := app.didRecvResponse(res) if err != nil { app.StopForError(err) @@ -129,7 +133,7 @@ func (app *remoteAppContext) recvResponseRoutine() { } } -func (app *remoteAppContext) didSendReq(reqres *reqRes) { +func (app *remoteAppContext) willSendReq(reqres *reqRes) { app.mtx.Lock() defer app.mtx.Unlock() app.reqSent.PushBack(reqres)