aboutsummaryrefslogtreecommitdiff
path: root/advtrains/log.lua
diff options
context:
space:
mode:
authorGabriel PĂ©rez-Cerezo <gabriel@gpcf.eu>2018-02-21 19:58:45 +0100
committerorwell96 <orwell@bleipb.de>2018-02-21 20:03:34 +0100
commit481f6218a8b377a0826b7e080046b5a890702e12 (patch)
tree3baa24616afb8790eb16f882863241b9f7d91523 /advtrains/log.lua
parent4c512f1dc5755efc7afd55b58078ec466442f648 (diff)
downloadadvtrains-481f6218a8b377a0826b7e080046b5a890702e12.tar.gz
advtrains-481f6218a8b377a0826b7e080046b5a890702e12.tar.bz2
advtrains-481f6218a8b377a0826b7e080046b5a890702e12.zip
Log certain events in a logfile in the world directory
(also fix the output of /at_sync_ndb)
Diffstat (limited to 'advtrains/log.lua')
-rw-r--r--advtrains/log.lua13
1 files changed, 13 insertions, 0 deletions
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