summaryrefslogtreecommitdiffstats
path: root/inc/eventlog.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2021-06-25 16:21:17 +0200
committerSimon Rettberg2021-06-25 16:21:17 +0200
commit32f0677dbca9e3347b931c1d0105eb37aa57e90d (patch)
treeddad4562e7ee8439a24e2462d44614692bb71d14 /inc/eventlog.inc.php
parentUpdate .idea (diff)
downloadslx-admin-32f0677dbca9e3347b931c1d0105eb37aa57e90d.tar.gz
slx-admin-32f0677dbca9e3347b931c1d0105eb37aa57e90d.tar.xz
slx-admin-32f0677dbca9e3347b931c1d0105eb37aa57e90d.zip
[eventlog] Add event filtering and notification system
Diffstat (limited to 'inc/eventlog.inc.php')
-rw-r--r--inc/eventlog.inc.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/inc/eventlog.inc.php b/inc/eventlog.inc.php
index 3ebb82a4..a29261b8 100644
--- a/inc/eventlog.inc.php
+++ b/inc/eventlog.inc.php
@@ -17,12 +17,14 @@ class EventLog
error_log($message);
return;
}
+ $data = [
+ 'type' => $type,
+ 'message' => $message,
+ 'details' => $details
+ ];
Database::exec("INSERT INTO eventlog (dateline, logtypeid, description, extra)"
- . " VALUES (UNIX_TIMESTAMP(), :type, :message, :details)", array(
- 'type' => $type,
- 'message' => $message,
- 'details' => $details
- ), true);
+ . " VALUES (UNIX_TIMESTAMP(), :type, :message, :details)", $data, true);
+ self::applyFilterRules('#serverlog', $data);
}
public static function failure($message, $details = '')
@@ -51,5 +53,16 @@ class EventLog
return;
Database::exec("TRUNCATE eventlog");
}
-
+
+ /**
+ * @param string $type the event. Will either be client state like ~poweron, ~runstate etc. or a client log type
+ * @param array $data A structured array containing event specific data that can be matched.
+ */
+ public static function applyFilterRules(string $type, array $data)
+ {
+ if (!Module::isAvailable('eventlog'))
+ return;
+ FilterRuleProcessor::applyFilterRules($type, $data);
+ }
+
}