Skip to content

Commit 555de71

Browse files
committed
[FAB-10018] space after tx-id in logs/errors
Based on a review comment. Change-Id: Ic69721aa95eb84f2cf4f4ffe70be3c91d39e89d6 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent 9406162 commit 555de71

File tree

4 files changed

+106
-106
lines changed

4 files changed

+106
-106
lines changed

core/chaincode/handler.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ type Handler struct {
148148

149149
// handleMessage is called by ProcessStream to dispatch messages.
150150
func (h *Handler) handleMessage(msg *pb.ChaincodeMessage) error {
151-
chaincodeLogger.Debugf("[%s]Fabric side Handling ChaincodeMessage of type: %s in state %s", shorttxid(msg.Txid), msg.Type, h.state)
151+
chaincodeLogger.Debugf("[%s] Fabric side Handling ChaincodeMessage of type: %s in state %s", shorttxid(msg.Txid), msg.Type, h.state)
152152

153153
if msg.Type == pb.ChaincodeMessage_KEEPALIVE {
154154
chaincodeLogger.Debug("Received KEEPALIVE Response")
@@ -170,7 +170,7 @@ func (h *Handler) handleMessageCreatedState(msg *pb.ChaincodeMessage) error {
170170
case pb.ChaincodeMessage_REGISTER:
171171
h.HandleRegister(msg)
172172
default:
173-
return fmt.Errorf("[%s]Fabric side handler cannot handle message (%s) while in created state", msg.Txid, msg.Type)
173+
return fmt.Errorf("[%s] Fabric side handler cannot handle message (%s) while in created state", msg.Txid, msg.Type)
174174
}
175175
return nil
176176
}
@@ -201,7 +201,7 @@ func (h *Handler) handleMessageReadyState(msg *pb.ChaincodeMessage) error {
201201
go h.HandleTransaction(msg, h.HandleQueryStateClose)
202202

203203
default:
204-
return fmt.Errorf("[%s]Fabric side handler cannot handle message (%s) while in ready state", msg.Txid, msg.Type)
204+
return fmt.Errorf("[%s] Fabric side handler cannot handle message (%s) while in ready state", msg.Txid, msg.Type)
205205
}
206206

207207
return nil
@@ -218,7 +218,7 @@ type handleFunc func(*pb.ChaincodeMessage, *TransactionContext) (*pb.ChaincodeMe
218218
// returened by the delegate are sent to the chat stream. Any errors returned by the
219219
// delegate are packaged as chaincode error messages.
220220
func (h *Handler) HandleTransaction(msg *pb.ChaincodeMessage, delegate handleFunc) {
221-
chaincodeLogger.Debugf("[%s]handling %s from chaincode", shorttxid(msg.Txid), msg.Type.String())
221+
chaincodeLogger.Debugf("[%s] handling %s from chaincode", shorttxid(msg.Txid), msg.Type.String())
222222
if !h.registerTxid(msg) {
223223
return
224224
}
@@ -238,11 +238,11 @@ func (h *Handler) HandleTransaction(msg *pb.ChaincodeMessage, delegate handleFun
238238

239239
if err != nil {
240240
err = errors.Wrapf(err, "%s failed: transaction ID: %s", msg.Type, msg.Txid)
241-
chaincodeLogger.Errorf("[%s]Failed to handle %s. error: %+v", shorttxid(msg.Txid), msg.Type, err)
241+
chaincodeLogger.Errorf("[%s] Failed to handle %s. error: %+v", shorttxid(msg.Txid), msg.Type, err)
242242
resp = &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_ERROR, Payload: []byte(err.Error()), Txid: msg.Txid, ChannelId: msg.ChannelId}
243243
}
244244

245-
chaincodeLogger.Debugf("[%s]Completed %s. Sending %s", shorttxid(msg.Txid), msg.Type, resp.Type)
245+
chaincodeLogger.Debugf("[%s] Completed %s. Sending %s", shorttxid(msg.Txid), msg.Type, resp.Type)
246246
h.serialSendAsync(resp, false)
247247
h.ActiveTransactions.Remove(msg.ChannelId, msg.Txid)
248248
}
@@ -286,7 +286,7 @@ func (h *Handler) serialSend(msg *pb.ChaincodeMessage) error {
286286

287287
var err error
288288
if err = h.chatStream.Send(msg); err != nil {
289-
err = errors.WithMessage(err, fmt.Sprintf("[%s]Error sending %s", shorttxid(msg.Txid), msg.Type))
289+
err = errors.WithMessage(err, fmt.Sprintf("[%s] Error sending %s", shorttxid(msg.Txid), msg.Type))
290290
chaincodeLogger.Errorf("%+v", err)
291291
}
292292
return err
@@ -385,7 +385,7 @@ func (h *Handler) ProcessStream(stream ccintf.ChaincodeStream) error {
385385
}
386386

387387
in := rMsg.msg
388-
chaincodeLogger.Debugf("[%s]Received message %s from shim", shorttxid(in.Txid), in.Type)
388+
chaincodeLogger.Debugf("[%s] Received message %s from shim", shorttxid(in.Txid), in.Type)
389389

390390
err := h.handleMessage(in)
391391
if err != nil {
@@ -486,7 +486,7 @@ func (h *Handler) Notify(msg *pb.ChaincodeMessage) {
486486
return
487487
}
488488

489-
chaincodeLogger.Debugf("[%s]notifying Txid:%s, channelID:%s", shorttxid(msg.Txid), msg.Txid, msg.ChannelId)
489+
chaincodeLogger.Debugf("[%s] notifying Txid:%s, channelID:%s", shorttxid(msg.Txid), msg.Txid, msg.ChannelId)
490490
tctx.ResponseNotifier <- msg
491491
tctx.CloseQueryIterators()
492492
}
@@ -514,7 +514,7 @@ func (h *Handler) registerTxid(msg *pb.ChaincodeMessage) bool {
514514
if h.chaincodeID != nil {
515515
chaincodeName = h.chaincodeID.Name
516516
}
517-
chaincodeLogger.Errorf("[%s]Another request pending for this CC: %s, Txid: %s, ChannelID: %s. Cannot process.", shorttxid(msg.Txid), chaincodeName, msg.Txid, msg.ChannelId)
517+
chaincodeLogger.Errorf("[%s] Another request pending for this CC: %s, Txid: %s, ChannelID: %s. Cannot process.", shorttxid(msg.Txid), chaincodeName, msg.Txid, msg.ChannelId)
518518
return false
519519
}
520520

@@ -540,7 +540,7 @@ func (h *Handler) HandleGetState(msg *pb.ChaincodeMessage, txContext *Transactio
540540
return nil, errors.WithStack(err)
541541
}
542542
if res == nil {
543-
chaincodeLogger.Debugf("[%s]No state associated with key: %s. Sending %s with an empty payload", shorttxid(msg.Txid), key, pb.ChaincodeMessage_RESPONSE)
543+
chaincodeLogger.Debugf("[%s] No state associated with key: %s. Sending %s with an empty payload", shorttxid(msg.Txid), key, pb.ChaincodeMessage_RESPONSE)
544544
}
545545

546546
// Send response msg back to chaincode. GetState will not trigger event

core/chaincode/handler_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,7 @@ var _ = Describe("Handler", func() {
20542054

20552055
It("returns an error", func() {
20562056
err := handler.ProcessStream(fakeChatStream)
2057-
Expect(err).To(MatchError("error handling message, ending stream: [tx-id]Fabric side handler cannot handle message (9999) while in created state"))
2057+
Expect(err).To(MatchError("error handling message, ending stream: [tx-id] Fabric side handler cannot handle message (9999) while in created state"))
20582058
})
20592059
})
20602060

@@ -2103,7 +2103,7 @@ var _ = Describe("Handler", func() {
21032103
Eventually(fakeChatStream.RecvCallCount).ShouldNot(Equal(0)) // wait for loop to start
21042104
handler.Execute(context.Background(), cccid, incomingMessage, time.Millisecond) // force async error
21052105

2106-
Eventually(errChan).Should(Receive(MatchError("received error while sending message, ending chaincode support stream: [tx-id]Error sending TRANSACTION: candy")))
2106+
Eventually(errChan).Should(Receive(MatchError("received error while sending message, ending chaincode support stream: [tx-id] Error sending TRANSACTION: candy")))
21072107
})
21082108

21092109
It("stops receiving messages", func() {

core/chaincode/platforms/golang/platform.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func getGopath() (string, error) {
8383
// Only take the first element of GOPATH
8484
splitGoPath := filepath.SplitList(env["GOPATH"])
8585
if len(splitGoPath) == 0 {
86-
return "", fmt.Errorf("invalid GOPATH environment variable value:[%s]", env["GOPATH"])
86+
return "", fmt.Errorf("invalid GOPATH environment variable value: %s", env["GOPATH"])
8787
}
8888
return splitGoPath[0], nil
8989
}

0 commit comments

Comments
 (0)