Commit 1a9e8c96 authored by Ad Schellevis's avatar Ad Schellevis

(configd) send configd client issues to syslog, closes https://github.com/opnsense/core/issues/464

parent 3026a561
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
*/ */
namespace OPNsense\Core; namespace OPNsense\Core;
use Phalcon\Logger\Adapter\Syslog;
/** /**
* Class Backend * Class Backend
* @package OPNsense\Core * @package OPNsense\Core
...@@ -48,6 +50,21 @@ class Backend ...@@ -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 * send event to backend
* @param string $event event string * @param string $event event string
...@@ -67,14 +84,16 @@ class Backend ...@@ -67,14 +84,16 @@ class Backend
sleep(1); sleep(1);
$timeout_wait -= 1; $timeout_wait -= 1;
if ($timeout_wait <= 0) { 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 = ""; $resp = "";
$stream = stream_socket_client('unix://'.$this->configdSocket, $errorNumber, $errorMessage, $poll_timeout); $stream = stream_socket_client('unix://'.$this->configdSocket, $errorNumber, $errorMessage, $poll_timeout);
if ($stream === false) { 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); stream_set_timeout($stream, $poll_timeout);
...@@ -97,7 +116,8 @@ class Backend ...@@ -97,7 +116,8 @@ class Backend
// handle timeouts // handle timeouts
if ((time() - $starttime) > $timeout) { if ((time() - $starttime) > $timeout) {
throw new \Exception("Timeout (".$timeout.") executing :".$event); $this->getLogger()->error("Failed to connect: $errorMessage");
return null;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment