Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Conversation

@Kelvin-M
Copy link
Contributor

Description

In case we use the same chaincode for multiple channel, like Substra/hlf-k8s#102, we need to log the channel name for each request to be able to review logs in case of troubleshooting sessions.

Closes issue(s)

None

Companion PRs

Substra/hlf-k8s#102

How to test / repro

Launch e2e tests (minimal) and look for chaincode logs :)

Screenshots / Trace


time="2020-11-25T10:39:38Z" level=info msg="Load TLS certificates"
time="2020-11-25T10:39:38Z" level=info msg="Start Substra ChaincodeServer"
time="2020-11-25T10:41:01Z" level=info msg="Args received by the chaincode on channel 'mychannel': []string{\"registerNode\", \"[\\\"\\\"]\"}"
time="2020-11-25T10:41:01Z" level=info msg="Response from chaincode on channel 'mychannel' (in 18ms): main.Node{ID:\"MyOrg1MSP\"}, error: %!s(<nil>)"
time="2020-11-25T10:41:02Z" level=info msg="Args received by the chaincode on channel 'yourchannel': []string{\"registerNode\", \"[\\\"\\\"]\"}"
time="2020-11-25T10:41:02Z" level=info msg="Response from chaincode on channel 'yourchannel' (in 23ms): main.Node{ID:\"MyOrg1MSP\"}, error: %!s(<nil>)"
time="2020-11-25T10:41:26Z" level=info msg="Args received by the chaincode on channel 'mychannel': []string{\"registerNode\", \"[\\\"\\\"]\"}"
time="2020-11-25T10:41:26Z" level=info msg="Response from chaincode on channel 'mychanne'l (in 7ms): main.Node{ID:\"MyOrg2MSP\"}, error: %!s(<nil>)"
time="2020-11-25T10:41:27Z" level=info msg="Args received by the chaincode on channel 'yourchannel': []string{\"registerNode\", \"[\\\"\\\"]\"}"
time="2020-11-25T10:41:27Z" level=info msg="Response from chaincode on channel 'yourchannel' (in 17ms): main.Node{ID:\"MyOrg2MSP\"}, error: %!s(<nil>)"

Changes include

  • Add channel name in Args received log line
  • Add channel name in Response from chaincode log line

Checklist

  • I have tested this code with e2e tests from substra-tests

Other comments

Feel free to change the format if you want to log it in a clearer way !


func main() {
logger.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

Copy link
Contributor

@AurelienGasser AurelienGasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition

@AurelienGasser
Copy link
Contributor

@Kelvin-M the last commit makes the code hard to read, maybe introduce a mockTxid variable and use it everywhere? Or better, set the tx id within MockInvoke

@AurelienGasser
Copy link
Contributor

@Kelvin-M please take a look at my latest changes, it'f that's OK with you I think we can merge.

Copy link
Member

@inelgnu inelgnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Kelvin-M Kelvin-M merged commit bd0e454 into master Nov 30, 2020
@Kelvin-M Kelvin-M deleted the add-channel-log branch November 30, 2020 10:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants