Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
more debugging for sendxmpp logger
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske committed Dec 1, 2014
1 parent 884e4dd commit eee192b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions scripts/test-xmpp.php
Expand Up @@ -3,6 +3,7 @@
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';
Expand Down
19 changes: 13 additions & 6 deletions src/callnotifier/Logger/CallSendXmpp.php
Expand Up @@ -8,7 +8,7 @@
class Logger_CallSendXmpp extends Logger_CallBase
{
protected $recipients;
protected $debug = false;
public $debug = false;

public function __construct($recipients, $callTypes = 'i', $msns = array())
{
Expand Down Expand Up @@ -61,19 +61,26 @@ protected function notify($msg)
$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";
}
}
}
}
Expand Down

0 comments on commit eee192b

Please sign in to comment.