summaryrefslogtreecommitdiffstats
path: root/library/Director/Daemon/LogProxy.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:31 +0000
commitf66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch)
treefbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Daemon/LogProxy.php
parentInitial commit. (diff)
downloadicingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz
icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--library/Director/Daemon/LogProxy.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/library/Director/Daemon/LogProxy.php b/library/Director/Daemon/LogProxy.php
new file mode 100644
index 0000000..0b58ae8
--- /dev/null
+++ b/library/Director/Daemon/LogProxy.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Icinga\Module\Director\Daemon;
+
+use Exception;
+use Icinga\Module\Director\Db;
+use function React\Promise\resolve;
+
+class LogProxy implements DbBasedComponent
+{
+ protected $connection;
+
+ protected $db;
+
+ protected $server;
+
+ protected $instanceUuid;
+
+ protected $prefix = '';
+
+ public function __construct($instanceUuid)
+ {
+ $this->instanceUuid = $instanceUuid;
+ }
+
+ public function setPrefix($prefix)
+ {
+ $this->prefix = $prefix;
+
+ return $this;
+ }
+
+ /**
+ * @param Db $connection
+ * @return \React\Promise\ExtendedPromiseInterface
+ */
+ public function initDb(Db $connection)
+ {
+ $this->connection = $connection;
+ $this->db = $connection->getDbAdapter();
+
+ return resolve();
+ }
+
+ /**
+ * @return \React\Promise\ExtendedPromiseInterface
+ */
+ public function stopDb()
+ {
+ $this->connection = null;
+ $this->db = null;
+
+ return resolve();
+ }
+
+ public function log($severity, $message)
+ {
+ Logger::$severity($this->prefix . $message);
+ /*
+ // Not yet
+ try {
+ if ($this->db) {
+ $this->db->insert('director_daemonlog', [
+ // environment/installation/db?
+ 'instance_uuid' => $this->instanceUuid,
+ 'ts_create' => DaemonUtil::timestampWithMilliseconds(),
+ 'level' => $severity,
+ 'message' => $message,
+ ]);
+ }
+ } catch (Exception $e) {
+ Logger::error($e->getMessage());
+ }
+ */
+ }
+}