debugged notification of availability of devices
This commit is contained in:
29
moha.php
29
moha.php
@ -50,7 +50,7 @@ if ($testMode)
|
||||
$httpServerIp = "192.168.1.253";
|
||||
}else
|
||||
{
|
||||
$logLevel = DEBUG | INFO | NOTICE | WARNING | ERROR | ALERT;
|
||||
$logLevel = INFO | NOTICE | WARNING | ERROR | ALERT;
|
||||
$mqttServerIp = "127.0.0.1"; // IP address of mqttserver in production mode
|
||||
$dataPath = "/usr/share/moha/";
|
||||
$logFile = "/var/log/moha.log"; // Path of log file
|
||||
@ -64,18 +64,25 @@ if (!init()) exit(1);
|
||||
bindtextdomain("moha", "./locale");
|
||||
textdomain("moha");
|
||||
|
||||
function notify($message, $destinataire=NOTIF_DEFAULT_DEST)
|
||||
function notify($message, $device)
|
||||
{
|
||||
global $notificationMethods;
|
||||
$result = false;
|
||||
|
||||
//TODO destinataire selon fichier de config
|
||||
$destinataire = array("daniel");
|
||||
|
||||
foreach($notificationMethods as $value)
|
||||
{
|
||||
$result = $result | $value->send($message, $destinataire);
|
||||
foreach($destinataire as $dest)
|
||||
{
|
||||
$result = $result | $value->send($message, $dest);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function logger($level, $log, $pos = "", $notif = true)
|
||||
function logger($level, $log, $pos = "", $device=null, $notif = true)
|
||||
{
|
||||
global $logFh, $logLevel, $notificationLevel, $logLevels;
|
||||
$logString = $logLevels[$level] . " " ;
|
||||
@ -92,7 +99,7 @@ function logger($level, $log, $pos = "", $notif = true)
|
||||
$test = $level & $notificationLevel;
|
||||
if (($test != 0) and ($notif === true))
|
||||
{
|
||||
if(notify("Moha\n" . $logString) === false)
|
||||
if(notify("Moha\n" . $logString, $device) === false)
|
||||
{
|
||||
logger(INFO, _("Notification not sent"), __FILE__ . ":" . __LINE__, false);
|
||||
return true;
|
||||
@ -331,10 +338,16 @@ while (true)
|
||||
$i = 1;
|
||||
foreach($hooks as $hookName => &$hook)
|
||||
{
|
||||
if ($hook->initialized === false); // and $hook->active === true)
|
||||
if ($hook->active === false)
|
||||
{
|
||||
logger(WARNING, _("Initializing Hook not completely initialized :") . $hookName, __FILE__ . ":" . __LINE__);
|
||||
$i &= $hook->installHooks($indexDevices);
|
||||
$i = 1;
|
||||
}else
|
||||
{
|
||||
if ($hook->initialized === false); // and $hook->active === true)
|
||||
{
|
||||
logger(WARNING, _("Initializing Hook not completely initialized :") . $hookName, __FILE__ . ":" . __LINE__);
|
||||
$i &= $hook->installHooks($indexDevices);
|
||||
}
|
||||
}
|
||||
}
|
||||
$hooksInitialized = $i;
|
||||
|
Reference in New Issue
Block a user