diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-07-15 22:48:25 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-07-15 22:48:25 +0200 |
| commit | 1350411a5e11e720eb7c7f528f6d579322f6021c (patch) | |
| tree | 9a0dd83fed0908e89135e109baebec270c1d6cb5 /src | |
| parent | fc647788cf137595e84bea72edb16d86ab1d76a5 (diff) | |
| download | auerswald-callnotifier-1350411a5e11e720eb7c7f528f6d579322f6021c.tar.gz auerswald-callnotifier-1350411a5e11e720eb7c7f528f6d579322f6021c.zip | |
decode debug bytes and display them in echo logger
Diffstat (limited to 'src')
| -rw-r--r-- | src/callnotifier/Logger/Echo.php | 15 |
1 files changed, 15 insertions, 0 deletions
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"; |
