From: Christian Weiske Date: Sun, 15 Jul 2012 20:48:25 +0000 (+0200) Subject: decode debug bytes and display them in echo logger X-Git-Tag: v1.0.0~87 X-Git-Url: https://git.cweiske.de/auerswald-callnotifier.git/commitdiff_plain/1350411a5e11e720eb7c7f528f6d579322f6021c decode debug bytes and display them in echo logger --- diff --git a/src/callnotifier/Logger/Echo.php b/src/callnotifier/Logger/Echo.php index eec9bb1..c716db8 100644 --- a/src/callnotifier/Logger/Echo.php +++ b/src/callnotifier/Logger/Echo.php @@ -9,6 +9,8 @@ class Logger_Echo implements Logger $this->begin = $cc->convert('%y'); $this->end = $cc->convert('%n'); $this->blue = $cc->convert('%b'); + $this->red = $cc->convert('%r'); + $this->white = $cc->convert('%w'); } public function log($type, $arData) @@ -16,6 +18,19 @@ class Logger_Echo implements Logger if ($type == 'msgData') { echo $this->begin . $arData['type'] . $this->end . ': ' . $arData['details'] . "\n"; + if (preg_match('#^[A-Z][0-9]{2}: (.+)$#', $arData['details'], $matches)) { + $bytestring = $matches[1]; + $line = ''; + foreach (explode(' ', $bytestring) as $strbyte) { + $line .= chr(hexdec($strbyte)); + } + $line = preg_replace( + '/[^[:print:]]/', + $this->white . '?' . $this->end, + $line + ); + echo $this->red . ' bytes' . $this->end . ': ' . $line . "\n"; + } } else { echo $this->blue . $type . $this->end . ': ' . var_export($arData, true) . "\n";