2 namespace callnotifier;
4 class Logger_Echo implements Logger
6 public function __construct()
8 $cc = new \Console_Color2();
9 $this->begin = $cc->convert('%y');
10 $this->end = $cc->convert('%n');
11 $this->blue = $cc->convert('%b');
12 $this->red = $cc->convert('%r');
13 $this->white = $cc->convert('%w');
14 $this->purple = $cc->convert('%p');
17 public function log($type, $arData)
19 if ($type == 'msgData') {
20 echo $this->begin . $arData['type'] . $this->end
21 . ': ' . $arData['details'] . "\n";
22 if (preg_match('#^[A-Z][0-9]{2}: (.+)$#', $arData['details'], $matches)) {
23 $bytestring = $matches[1];
25 foreach (explode(' ', $bytestring) as $strbyte) {
26 $line .= chr(hexdec($strbyte));
30 $this->white . '?' . $this->end,
33 echo $this->red . ' bytes' . $this->end . ': ' . $line . "\n";
35 } else if ($type == 'edss1msg') {
36 $msg = $arData['msg'];
38 $this->purple . 'EDSS1_Message' . $this->end
40 . $this->purple . '%s' . $this->end
41 . ' SAPI %d, CR %d, TEI %d, call %d'
49 count($msg->parameters)
51 foreach ($msg->parameters as $param) {
53 " Parameter type %02X%s, %d bytes: %s\n",
56 ? ' ' . $this->purple . $param->title . $this->end
59 preg_replace('/[^[:print:]]/', '?', $param->data)
60 . (isset($param->number)
61 ? ' ' . $this->red . $param->number . $this->end
67 echo $this->blue . $type . $this->end . ': '
68 . var_export($arData, true) . "\n";