mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
(configd) send configd client issues to syslog, closes https://github.com/opnsense/core/issues/464
This commit is contained in:
parent
3026a561d3
commit
1a9e8c9694
@ -29,6 +29,8 @@
|
||||
*/
|
||||
namespace OPNsense\Core;
|
||||
|
||||
use Phalcon\Logger\Adapter\Syslog;
|
||||
|
||||
/**
|
||||
* Class Backend
|
||||
* @package OPNsense\Core
|
||||
@ -48,6 +50,21 @@ class Backend
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* get system logger
|
||||
* @param string $ident syslog identifier
|
||||
* @return Syslog log handler
|
||||
*/
|
||||
protected function getLogger($ident = "configd")
|
||||
{
|
||||
$logger = new Syslog($ident, array(
|
||||
'option' => LOG_PID,
|
||||
'facility' => LOG_LOCAL4
|
||||
));
|
||||
|
||||
return $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* send event to backend
|
||||
* @param string $event event string
|
||||
@ -67,14 +84,16 @@ class Backend
|
||||
sleep(1);
|
||||
$timeout_wait -= 1;
|
||||
if ($timeout_wait <= 0) {
|
||||
throw new \Exception("failed waiting for configd (doesn't seem to be running)");
|
||||
$this->getLogger()->error("failed waiting for configd (doesn't seem to be running)");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$resp = "";
|
||||
$stream = stream_socket_client('unix://'.$this->configdSocket, $errorNumber, $errorMessage, $poll_timeout);
|
||||
if ($stream === false) {
|
||||
throw new \Exception("Failed to connect: $errorMessage");
|
||||
$this->getLogger()->error("Failed to connect: $errorMessage");
|
||||
return null;
|
||||
}
|
||||
|
||||
stream_set_timeout($stream, $poll_timeout);
|
||||
@ -97,7 +116,8 @@ class Backend
|
||||
|
||||
// handle timeouts
|
||||
if ((time() - $starttime) > $timeout) {
|
||||
throw new \Exception("Timeout (".$timeout.") executing :".$event);
|
||||
$this->getLogger()->error("Failed to connect: $errorMessage");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user