git.cweiske.de
/
auerswald-callnotifier.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d0ff314
)
Add debug message output to call loggers
author
Christian Weiske
<cweiske@cweiske.de>
Wed, 13 Mar 2019 16:01:30 +0000
(17:01 +0100)
committer
Christian Weiske
<cweiske@cweiske.de>
Wed, 13 Mar 2019 16:01:30 +0000
(17:01 +0100)
src/callnotifier/CLI.php
patch
|
blob
|
history
src/callnotifier/Log.php
patch
|
blob
|
history
src/callnotifier/Logger/CallBase.php
patch
|
blob
|
history
src/callnotifier/Logger/CallDreambox.php
patch
|
blob
|
history
diff --git
a/src/callnotifier/CLI.php
b/src/callnotifier/CLI.php
index 0b8ae60773c1cac7a48ca2dfa51776aa4b9bb7b2..564a5f5a1985692b828b6e8b39a4a5dd645d35e6 100644
(file)
--- a/
src/callnotifier/CLI.php
+++ b/
src/callnotifier/CLI.php
@@
-133,7
+133,7
@@
class CLI
*
* @return string Full path of config file or NULL if no file found
*/
*
* @return string Full path of config file or NULL if no file found
*/
- p
rotected
function getConfigFile()
+ p
ublic
function getConfigFile()
{
if (basename(dirname(__DIR__)) == 'src'
&& file_exists(__DIR__ . '/../../data/callnotifier.config.php')
{
if (basename(dirname(__DIR__)) == 'src'
&& file_exists(__DIR__ . '/../../data/callnotifier.config.php')
@@
-157,4
+157,4
@@
class CLI
}
}
}
}
-?>
\ No newline at end of file
+?>
diff --git
a/src/callnotifier/Log.php
b/src/callnotifier/Log.php
index d2ee0c83a42e083fd1f764294c43ea2db84c3012..a831066540196d587782fd7e484c625bf3a51da9 100644
(file)
--- a/
src/callnotifier/Log.php
+++ b/
src/callnotifier/Log.php
@@
-3,6
+3,8
@@
namespace callnotifier;
class Log
{
class Log
{
+ public $debug = false;
+
/**
* Array of logger object arrays.
* Key is the notification type, value is an array of logger objects
/**
* Array of logger object arrays.
* Key is the notification type, value is an array of logger objects
@@
-33,6
+35,10
@@
class Log
}
$types = (array)$types;
}
$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);
foreach ($types as $type) {
if (!isset($this->logger[$type])) {
throw new \Exception('Unknown log type: ' . $type);
@@
-46,9
+52,12
@@
class Log
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 (count($this->logger[$type])) {
foreach ($this->logger[$type] as $logger) {
+ if ($this->debug) {
+ echo "Logging to " . get_class($logger) . "\n";
+ }
$logger->log($type, $arData);
}
}
$logger->log($type, $arData);
}
}
diff --git
a/src/callnotifier/Logger/CallBase.php
b/src/callnotifier/Logger/CallBase.php
index 31ad0bc7ce8408af85115d75081e0b24939d82f0..2a1d3e8a22bc533c401be8143201b7144c53fd4d 100644
(file)
--- a/
src/callnotifier/Logger/CallBase.php
+++ b/
src/callnotifier/Logger/CallBase.php
@@
-6,6
+6,7
@@
abstract class Logger_CallBase implements Logger
protected $callTypes;
protected $msns;
protected $callTypes;
protected $msns;
+ public $debug = false;
/**
* Create a new call logger.
/**
* Create a new call logger.
@@
-33,9
+34,11
@@
abstract class Logger_CallBase implements Logger
protected function hasValidType($call)
{
if ($call->type == CallMonitor_Call::INCOMING && $this->callTypes == 'o') {
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') {
return false;
}
if ($call->type == CallMonitor_Call::OUTGOING && $this->callTypes == 'i') {
+ $this->debug('No valid call type (requested: i)');
return false;
}
return false;
}
@@
-56,6
+59,7
@@
abstract class Logger_CallBase implements Logger
}
if (count($this->msns) > 0 && !in_array($msn, $this->msns)) {
//msn shall not be logged
}
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 false;
}
@@
-100,6
+104,13
@@
abstract class Logger_CallBase implements Logger
return str_pad($number, 12, ' ', STR_PAD_RIGHT);
}
return str_pad($number, 12, ' ', STR_PAD_RIGHT);
}
+ protected function debug($msg)
+ {
+ if (!$this->debug) {
+ return;
+ }
+ echo $msg . "\n";
+ }
}
?>
}
?>
diff --git
a/src/callnotifier/Logger/CallDreambox.php
b/src/callnotifier/Logger/CallDreambox.php
index f5da0f98aa1f5e7b8f673564702a4b041b02fe69..81dd63abaab178218059f9d708d029f668d08ce9 100644
(file)
--- a/
src/callnotifier/Logger/CallDreambox.php
+++ b/
src/callnotifier/Logger/CallDreambox.php
@@
-54,6
+54,8
@@
class Logger_CallDreambox extends Logger_CallBase
{
$url = 'http://' . $this->host
. '/web/message?type=2&timeout=10&text=' . urlencode($msg);
{
$url = 'http://' . $this->host
. '/web/message?type=2&timeout=10&text=' . urlencode($msg);
+ $this->debug('Fetch: ' . $url);
+
exec(
'curl'
. ' ' . escapeshellarg($url)
exec(
'curl'
. ' ' . escapeshellarg($url)