bobbingwide / oik-bwtrace

debug trace for WordPress
https://www.oik-plugins.com/oik-plugins/oik-bwtrace-debug-trace-for-wordpress/
GNU General Public License v2.0
6 stars 1 forks source link

Add hex dump support for trace output #76

Closed bobbingwide closed 4 years ago

bobbingwide commented 5 years ago

Sometimes, when you want to see the exact contents of data a print_r() is not good enough. We need to be able to see a hex dump of each character.

Proposed solution

Provide a helper function to return data in hex dump format.

bobbingwide commented 4 years ago

In the first version I'll just include the helper functon bw_trace_hexdump which will load and call oik_hexdump from the hexdump shared library. oik-bwtrace will deliver the hexdump library in the libs folder. This file will need to be added to the oik-libs repository. The hexdump logic is currently tested in oik-batch.

bobbingwide commented 4 years ago

The hexdump function was written to support single byte characters. To hexdump the first line of Hello Dolly add the following code in hello_dolly_get_lyric()

$lyr = bw_trace_hexdump( $lyrics[0]);
bw_trace2( $lyr, "lyric");

The hexdump output for the first line of "Hello Dolly" is

13
Hello, Dolly........ 48 65 6c 6c 6f 2c 20 44 6f 6c 6c 79 0d 

Notes: