*
* @return string Full path of config file or NULL if no file found
*/
- protected function getConfigFile()
+ public function getConfigFile()
{
if (basename(dirname(__DIR__)) == 'src'
&& file_exists(__DIR__ . '/../../data/callnotifier.config.php')
}
}
-?>
\ No newline at end of file
+?>
class Log
{
+ public $debug = false;
+
/**
* Array of logger object arrays.
* Key is the notification type, value is an array of logger objects
}
$types = (array)$types;
+ if ($this->debug) {
+ $logger->debug = $this->debug;
+ }
+
foreach ($types as $type) {
if (!isset($this->logger[$type])) {
throw new \Exception('Unknown log type: ' . $type);
if (!isset($this->logger[$type])) {
throw new \Exception('Unknown log type: ' . $type);
}
-
+
if (count($this->logger[$type])) {
foreach ($this->logger[$type] as $logger) {
+ if ($this->debug) {
+ echo "Logging to " . get_class($logger) . "\n";
+ }
$logger->log($type, $arData);
}
}
protected $callTypes;
protected $msns;
+ public $debug = false;
/**
* Create a new call logger.
protected function hasValidType($call)
{
if ($call->type == CallMonitor_Call::INCOMING && $this->callTypes == 'o') {
+ $this->debug('No valid call type (requested: o)');
return false;
}
if ($call->type == CallMonitor_Call::OUTGOING && $this->callTypes == 'i') {
+ $this->debug('No valid call type (requested: i)');
return false;
}
}
if (count($this->msns) > 0 && !in_array($msn, $this->msns)) {
//msn shall not be logged
+ $this->debug('No valid MSN (requested: ' . $msn . ')');
return false;
}
return str_pad($number, 12, ' ', STR_PAD_RIGHT);
}
+ protected function debug($msg)
+ {
+ if (!$this->debug) {
+ return;
+ }
+ echo $msg . "\n";
+ }
}
?>
{
$url = 'http://' . $this->host
. '/web/message?type=2&timeout=10&text=' . urlencode($msg);
+ $this->debug('Fetch: ' . $url);
+
exec(
'curl'
. ' ' . escapeshellarg($url)