some debugging and separating callbacks of the main program
This commit is contained in:
36
utils.php
36
utils.php
@ -5,11 +5,6 @@ function now()
|
||||
return new DateTime("now");
|
||||
}
|
||||
|
||||
function signalHandler($signal)
|
||||
{
|
||||
endMoha();
|
||||
}
|
||||
|
||||
function notify($message)
|
||||
{
|
||||
global $notificationMethods;
|
||||
@ -21,29 +16,18 @@ function notify($message)
|
||||
return $result;
|
||||
}
|
||||
|
||||
function logger($level, $log, $notif = true)
|
||||
{
|
||||
global $logFh, $logLevel, $notificationLevel;
|
||||
//echo "=====>>>> $level => $logLevel => $notificationLevel" . EOL ;
|
||||
//echo $log .EOL;
|
||||
if ($level & $logLevel)
|
||||
{
|
||||
fwrite($logFh, "$level : $log" . EOL);
|
||||
print ("$level : $log" . EOL);
|
||||
}
|
||||
$test = $level & $notificationLevel;
|
||||
//echo "notif =>" .$notif . EOL;
|
||||
if (($test != 0) and ($notif === true))
|
||||
{
|
||||
if(notify("Moha\n" . $log) === false)
|
||||
{
|
||||
logger(INFO, _("Notification not sent"), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mktopic($device)
|
||||
{
|
||||
return $device->topic . "/" . $device->friendlyName;
|
||||
}
|
||||
|
||||
logger(DEBUG, _("signal handling"), false);
|
||||
//signal handling
|
||||
function signalHandler($signal)
|
||||
{
|
||||
endMoha();
|
||||
}
|
||||
pcntl_signal(SIGTERM, 'signalHandler');// Termination ('kill' was called)
|
||||
pcntl_signal(SIGHUP, 'signalHandler'); // Terminal log-out
|
||||
pcntl_signal(SIGINT, 'signalHandler');
|
||||
?>
|
||||
|
Reference in New Issue
Block a user