From 32f0677dbca9e3347b931c1d0105eb37aa57e90d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 25 Jun 2021 16:21:17 +0200 Subject: [eventlog] Add event filtering and notification system --- inc/eventlog.inc.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'inc/eventlog.inc.php') 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); + } + } -- cgit v1.2.3-55-g7522