From eee192bea92b2c206dd172a03287438185d58bfc Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 1 Dec 2014 18:11:57 +0100 Subject: [PATCH] more debugging for sendxmpp logger --- scripts/test-xmpp.php | 1 + src/callnotifier/Logger/CallSendXmpp.php | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/test-xmpp.php b/scripts/test-xmpp.php index b59d9f1..b7504e4 100644 --- a/scripts/test-xmpp.php +++ b/scripts/test-xmpp.php @@ -3,6 +3,7 @@ namespace callnotifier; require_once __DIR__ . '/../tests/bootstrap.php'; $l = new Logger_CallSendXmpp('cweiske@cweiske.de', 'i', array('12345')); +$l->debug = true; $call = new CallMonitor_Call(); $call->type = 'i'; diff --git a/src/callnotifier/Logger/CallSendXmpp.php b/src/callnotifier/Logger/CallSendXmpp.php index c970430..33fc6da 100644 --- a/src/callnotifier/Logger/CallSendXmpp.php +++ b/src/callnotifier/Logger/CallSendXmpp.php @@ -8,7 +8,7 @@ namespace callnotifier; class Logger_CallSendXmpp extends Logger_CallBase { protected $recipients; - protected $debug = false; + public $debug = false; public function __construct($recipients, $callTypes = 'i', $msns = array()) { @@ -61,19 +61,26 @@ class Logger_CallSendXmpp extends Logger_CallBase $runInBackground = ' > /dev/null 2>&1 &'; if ($this->debug) { $runInBackground = ''; - echo $msg . "\n"; + echo "Message:\n" . $msg . "\n"; + echo 'Sending to ' . count((array) $this->recipients) + . " recipients\n"; } foreach ((array)$this->recipients as $recipient) { //use system instead of exec to make debugging possible - system( - 'echo ' . escapeshellarg($msg) + $cmd = 'echo ' . escapeshellarg($msg) . ' | sendxmpp' . ' --message-type=headline'//no offline storage . ' --resource callnotifier' . ' ' . escapeshellarg($recipient) - . $runInBackground - ); + . $runInBackground; + if ($this->debug) { + echo "Executing:\n" . $cmd . "\n"; + } + system($cmd, $retval); + if ($this->debug) { + echo 'Exit code: ' . $retval . "\n"; + } } } } -- 2.30.2