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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • douhuiyan2772 2019-03-27 12:32
    关注

    The logs for chaincodes are in their respective containers. So for a chaincode called mycc at version 1.0 on peer0 of org, I'd run:

    docker logs -f dev-peer0.org.example.com-mycc-1.0
    

    to see the output of any fmt.Print*s.

    Just in case someone is unfamiliar, you can view your containers with docker ps and the chaincode container is created after you install a chaincode and run instantiate on a new chaincode or upgrade an existing one (this creates a new container, hence the version in the container name above).

    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我需要在PC端 开两个抖店工作台客户端.(语言-java)
  • ¥15 有没有哪位厉害的人可以用C#可视化呀
  • ¥15 可以帮我看看代码哪里错了吗
  • ¥15 设计一个成绩管理系统
  • ¥15 PCL注册的选点等函数如何取消注册
  • ¥15 问一下各位,为什么我用蓝牙直接发送模拟输入的数据,接收端显示乱码呢,米思齐软件上usb串口显示正常的字符串呢?
  • ¥15 Python爬虫程序
  • ¥15 crypto 这种的应该怎么找flag?
  • ¥15 代码已写好,求帮我指出错误,有偿!
  • ¥15 matlab+波形匹配算法