file call logger
[auerswald-callnotifier.git] / src / callnotifier / CLI.php
index f9a4937742bb192a854792bdff20cccf8929fc24..6165f15550a56cd71be319125782e28f7be827a6 100644 (file)
@@ -23,8 +23,49 @@ class CLI
 
         $this->fillConfig($this->config, $result);
 
-        $handler = new MessageHandler($this->config);
-        $handler->addLogger(new Logger_Echo(), '*');
+        $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('startingCall', 'finishedCall')
+        );
+
+        $callMonitor = new CallMonitor($this->config, $log);
+        /*
+        $callMonitor->addDetailler(
+            new CallMonitor_Detailler_LDAP(
+                array(
+                    'host' => 'ldap.home.cweiske.de',
+                    'basedn' => 'ou=adressbuch,dc=cweiske,dc=de',
+                    'binddn' => 'cn=readonly,ou=users,dc=cweiske,dc=de',
+                    'bindpw' => 'readonly'
+                )
+            )
+        );
+        $callMonitor->addDetailler(
+            new CallMonitor_Detailler_OpenGeoDb(
+                'mysql:host=dojo;dbname=opengeodb',
+                'opengeodb-read',
+                'opengeodb'
+            )
+        );
+        */
+
+        $log->addLogger(
+            new Logger_CallFile('incoming.log', 'i', '40862'),
+            array('finishedCall')
+        );
+        $log->addLogger(
+            new Logger_CallFile('all.log'),
+            array('finishedCall')
+        );
+
+        $handler = new MessageHandler($this->config, $log, $callMonitor);
 
         if ($this->config->replayFile !== null) {
             $sourceClass = 'callnotifier\Source_File';
@@ -71,6 +112,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;
     }