call echo logger
[auerswald-callnotifier.git] / src / callnotifier / CLI.php
index 928e4ce929cac281f34ac9118a2efd87609f6ed1..6ec9a7e40938664dbcabe6e91b738597e95dd0f0 100644 (file)
@@ -23,7 +23,22 @@ class CLI
 
         $this->fillConfig($this->config, $result);
 
-        $handler = new MessageHandler($this->config);
+        $log = new Log();
+        if ($result->options['debug'] || $result->options['debugEdss1']) {
+            $debugLogger = new Logger_Debug();
+            $log->addLogger($debugLogger, '*');
+            if ($result->options['debugEdss1']) {
+                $debugLogger->edss1MsgOnly = true;
+            }
+        }
+        $log->addLogger(
+            new Logger_CallEcho(), array('incomingCall', 'finishedCall')
+        );
+
+        $callMonitor = new CallMonitor($this->config, $log);
+
+        $handler = new MessageHandler($this->config, $log, $callMonitor);
+
         if ($this->config->replayFile !== null) {
             $sourceClass = 'callnotifier\Source_File';
         } else {
@@ -69,6 +84,25 @@ class CLI
             )
         );
 
+        $p->addOption(
+            'debug',
+            array(
+                'short_name'  => '-d',
+                'long_name'   => '--debug',
+                'description' => "Debug mode: Echo all received messages and events",
+                'action'      => 'StoreTrue'
+            )
+        );
+        $p->addOption(
+            'debugEdss1',
+            array(
+                'short_name'  => '-e',
+                'long_name'   => '--debug-edss1',
+                'description' => "Debug mode: Show EDSS1 messages only",
+                'action'      => 'StoreTrue'
+            )
+        );
+
         $this->cliParser = $p;
     }