improved debugging function (dumps raw bytes better)
This commit is contained in:
parent
7caa92b6d7
commit
c5f2f62777
1 changed files with 14 additions and 3 deletions
17
snaphax.php
17
snaphax.php
|
@ -94,9 +94,20 @@
|
|||
$this->options = $options;
|
||||
}
|
||||
|
||||
private function debug($text) {
|
||||
if ($this->options['debug'])
|
||||
echo "SNAPHAX DEBUG: $text\n";
|
||||
private function debug($text, $binary = false) {
|
||||
if ($this->options['debug']) {
|
||||
echo "SNAPHAX DEBUG: $text";
|
||||
if ($binary !== false) {
|
||||
// shortened hex repr of binary
|
||||
$len = strlen($binary);
|
||||
$tmp = " hex ($len bytes): ";
|
||||
$tmp.= join(' ', array_map('dechex', array_map('ord', str_split(substr($binary, 0, 16)))));
|
||||
$tmp.= ' ... ';
|
||||
$tmp.= join(' ', array_map('dechex', array_map('ord', str_split(substr($binary, -16)))));
|
||||
echo $tmp;
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
private function isValidBlobHeader($header) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue