add cli option to activate debug log
authorChristian Weiske <cweiske@cweiske.de>
Wed, 25 Jul 2012 16:19:25 +0000 (18:19 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 25 Jul 2012 16:19:25 +0000 (18:19 +0200)
src/callnotifier/CLI.php

index c8c8573..55f7f71 100644 (file)
@@ -24,7 +24,13 @@ class CLI
         $this->fillConfig($this->config, $result);
 
         $handler = new MessageHandler($this->config);
-        $handler->addLogger(new Logger_Debug(), '*');
+        if ($result->options['debug'] || $result->options['debugEdss1']) {
+            $debugLogger = new Logger_Debug();
+            $handler->addLogger($debugLogger, '*');
+            if ($result->options['debugEdss1']) {
+                $debugLogger->edss1MsgOnly = true;
+            }
+        }
 
         if ($this->config->replayFile !== null) {
             $sourceClass = 'callnotifier\Source_File';
@@ -71,6 +77,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;
     }