Skip to content

Consider hex output with DEBUG flags. #56

Description

@Raynos

I noticed that hypercore outputs debug data

  hypercore-protocol recv data 1 {
  index: 37,
  value: <Buffer 0a 0a 68 65 61 64 65 72 2e 73 76 67 12 22 08 a4 83 02 10 00 18 00 20 d3 ba 01 28 01 30 15 38 af db 05 40 fe cd cd d5 85 2f 48 fe cd cd d5 85 2f 1a 0b ... 15 more bytes>,
  nodes: [],
  signature: null
} +5ms

The data is being output as native Buffer pretty print from node core.

Consider using a hex pretty printing module like (https://github.com/Raynos/hexer-min).

I've done this before with PRETTY_HEX=1 DEBUG=* node program.js where i would use a different environment variable to hexdump the buffers in a hex friendly readable fashion.

Here's an example of hex printing.

  hypercore-protocol recv data 1 {
  index: 43,
  value: <Buffer 0a 0c 69 6d 67 2f 69 6e 64 65 78 2e 6a 73 12 21 08 a4 83 02 10 00 18 00 20 be 12 28 01 30 1a 38 fb c5 0b 40 a3 9e f6 d5 85 2f 48 a3 9e f6 d5 85 2f 1a ... 17 more bytes>,
  nodes: [],
  signature: null
} +4ms
  hypercore-protocol recv data hex +0ms
00: 0a0c 696d 672f 696e 6465 782e 6a73 1221  ..img/index.js.!
10: 08a4 8302 1000 1800 20be 1228 0130 1a38  ........ ..(.0.8
20: fbc5 0b40 a39e f6d5 852f 48a3 9ef6 d585  ...@...../H.....
30: 2f1a 0c23 0106 2325 210c 2a21 2201 1f20  /..#..#%!.*!".. 
40: 2b28 00                                  +(.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions