Skip to content

Conversation

@ggwpez
Copy link
Contributor

@ggwpez ggwpez commented Jun 7, 2021

Log the message type instead of a binary blob.

Closes #95

@ggwpez ggwpez requested a review from matthiasgeihs June 7, 2021 10:17
@ggwpez ggwpez force-pushed the 95-log-msg-type branch from 6a4ea9c to fbac261 Compare June 7, 2021 10:37
Copy link
Contributor

@matthiasgeihs matthiasgeihs left a comment

Choose a reason for hiding this comment

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

I agree that just printing the raw message data structure is not easily digestible for a human reader. However, sometimes you might still want more than just the type.

I suggest Printf("%v: %v", msg.Type(), msg).

You may also consider:

  • Implement the Stringer interface for wire.Msg
  • Use %T for printing the type. E.g., Printf("%T: %v", msg, msg)
  • Use %+v for more context on the data fields.

@ggwpez
Copy link
Contributor Author

ggwpez commented Jun 7, 2021

Implement the Stringer interface for wire.Msg

Since wire.Msg itself is an interface, (and golang does not have dynamic dispatching) I think the change would be too large.

I suggest Printf("%v: %v", msg.Type(), msg).

Ok i will use Printf("%v: %+v", msg.Type(), msg) then, with the %+v.

Use %T for printing the type. E.g., Printf("%T: %v", msg, msg)

%T formats it a bit differently, eg: as *client.msgChannelUpdateAcc instead of ChannelUpdateAcc.

Use %+v for more context on the data fields.

Check

@ggwpez ggwpez force-pushed the 95-log-msg-type branch from fbac261 to 9d2813f Compare June 7, 2021 10:54
Signed-off-by: Oliver Tale-Yazdi <oliver@perun.network>
@ggwpez ggwpez changed the title Log message type instead of binary. Log message type. Jun 7, 2021
@ggwpez ggwpez force-pushed the 95-log-msg-type branch from 9d2813f to 4bbe252 Compare June 7, 2021 10:58
@ggwpez ggwpez requested a review from matthiasgeihs June 7, 2021 11:01
@ggwpez ggwpez self-assigned this Jun 7, 2021
@matthiasgeihs matthiasgeihs merged commit fe2f0dc into hyperledger-labs:dev Jun 8, 2021
@matthiasgeihs matthiasgeihs deleted the 95-log-msg-type branch June 8, 2021 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log message type

2 participants