Skip to content

Commit

Permalink
Add log printer for ioctl (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frankonly authored and raullenchai committed Mar 23, 2019
1 parent 5535548 commit a632b45
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cli/ioctl/cmd/action/actionhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,23 @@ func printActionProto(action *iotextypes.Action) (string, error) {
}

func printReceiptProto(receipt *iotextypes.Receipt) string {
lines := make([]string, 0)
for _, l := range receipt.Logs {
line := fmt.Sprintf("#%d block:%d txHash:%s address:%s data:%s\n",
l.Index, l.BlockNumber, l.TxnHash, l.Address, l.Data)
for _, t := range l.Topics {
line += fmt.Sprintf(" %s\n", t)
}
lines = append(lines, line)
}
return fmt.Sprintf("returnValue: %x\n", receipt.ReturnValue) +
fmt.Sprintf("status: %d %s\n", receipt.Status,
match(strconv.Itoa(int(receipt.Status)), "status")) +
fmt.Sprintf("actHash: %x\n", receipt.ActHash) +
fmt.Sprintf("gasConsumed: %d\n", receipt.GasConsumed) +
fmt.Sprintf("contractAddress: %s %s\n", receipt.ContractAddress,
match(receipt.ContractAddress, "address"))
//TODO: print logs
match(receipt.ContractAddress, "address")) +
fmt.Sprintf("logs:\n%s", lines)
}

func match(in string, matchType string) string {
Expand Down

0 comments on commit a632b45

Please sign in to comment.