From 481f6218a8b377a0826b7e080046b5a890702e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Wed, 21 Feb 2018 19:58:45 +0100 Subject: Log certain events in a logfile in the world directory (also fix the output of /at_sync_ndb) --- advtrains/log.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 advtrains/log.lua (limited to 'advtrains/log.lua') diff --git a/advtrains/log.lua b/advtrains/log.lua new file mode 100644 index 0000000..d2b71d3 --- /dev/null +++ b/advtrains/log.lua @@ -0,0 +1,13 @@ +-- Log accesses to driver stands and changes to switches + +advtrains.log = function() end + +if minetest.settings:get_bool("advtrains_enable_logging") then + advtrains.logfile = advtrains.fpath .. "_log" + + function advtrains.log (event, player, pos, data) + local log = io.open(advtrains.logfile, "a+") + log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n") + log:close() + end +end -- cgit v1.2.3