changeset 4935:ae83200fb55f

mod_audit: make the extension of the module API less of a hack Thanks, Zash, for making me look at mod_http.
author Jonas Schäfer <jonas@wielicki.name>
date Tue, 26 Apr 2022 22:42:09 +0200 (2022-04-26)
parents 08dea42a302a
children a85efae90e21
files mod_audit/mod_audit.lua
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mod_audit/mod_audit.lua	Tue Apr 26 22:37:13 2022 +0200
+++ b/mod_audit/mod_audit.lua	Tue Apr 26 22:42:09 2022 +0200
@@ -2,6 +2,7 @@
 
 local time_now = os.time;
 local st = require "util.stanza";
+local moduleapi = require "core.moduleapi";
 
 local host_wide_user = "@";
 
@@ -77,10 +78,8 @@
 	end
 end
 
-local module_api = getmetatable(module).__index;
-
-function module_api:audit(user, event_type, extra)
-	audit(self.host, user, "mod_" .. self:get_name(), event_type, extra);
+function moduleapi.audit(module, user, event_type, extra)
+	audit(module.host, user, "mod_" .. module:get_name(), event_type, extra);
 end
 
 module:hook("audit", audit, 0);