dongqun9403 2019-03-15 18:15
浏览 338
已采纳

在Hyperledger架构中,如何打印出链码函数的消息和日志?

I want to test my chaincode by Golang, so I have used Hyperledger fabric chaincodedev test.

All functions of chaincode (invoke, query, etc.) worked, but there are no logs and messages of chaincode on console.

Logging is set to "debug" in every case.

I want to print out result message of invoke, query on console, but just print out message: "myc"; "myc"; "myc"; ...

2019-03-15 18:07:04.550 UTC [shim] setupChaincodeLogging -> INFO 001 Chaincode log level not provided; defaulting to: INFO
2019-03-15 18:07:04.550 UTC [shim] setupChaincodeLogging -> INFO 002 Chaincode (build level: ) starting up ...
2019-03-15 18:07:04.551 UTC [bccsp] initBCCSP -> DEBU 001 Initialize BCCSP [SW]
2019-03-15 18:07:04.551 UTC [grpc] DialContext -> DEBU 002 parsed scheme: ""
2019-03-15 18:07:04.551 UTC [grpc] DialContext -> DEBU 003 scheme "" not registered, fallback to default scheme
2019-03-15 18:07:04.551 UTC [grpc] watcher -> DEBU 004 ccResolverWrapper: sending new addresses to cc: [{peer:7052 0  <nil>}]
2019-03-15 18:07:04.551 UTC [grpc] switchBalancer -> DEBU 005 ClientConn switching balancer to "pick_first"
2019-03-15 18:07:04.551 UTC [grpc] HandleSubConnStateChange -> DEBU 006 pickfirstBalancer: HandleSubConnStateChange: 0xc00038eca0, CONNECTING
2019-03-15 18:07:04.552 UTC [grpc] HandleSubConnStateChange -> DEBU 007 pickfirstBalancer: HandleSubConnStateChange: 0xc00038eca0, READY

myc myc myc myc myc myc myc

enter image description here

  • 写回答

2条回答 默认 最新

  • douhuang2673 2019-03-16 02:02
    关注

    It's look like fmt.Println output.

    But you can user

    shim.NewLogger("YOUR_COMPONENT_NAME")
    

    You can found an example of shim logger :

    https://github.com/IBM-Blockchain-Archive/fabric-boilerplate/blob/master/blockchain/src/build-chaincode/chaincode.go

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 请教 麒麟系统挂载怎么安装
  • ¥15 如何在ns3中实现路径的自由切换
  • ¥20 SpringBoot+Vue3
  • ¥15 IT从业者的调查问卷
  • ¥65 LineageOs-21.0系统编译问题
  • ¥30 关于#c++#的问题,请各位专家解答!
  • ¥15 App的会员连续扣费
  • ¥15 不同数据类型的特征融合应该怎么做
  • ¥15 用proteus软件设计一个基于8086微处理器的简易温度计
  • ¥15 用联想小新14Pro