aboutsummaryrefslogtreecommitdiff
path: root/advtrains/log.lua
diff options
context:
space:
mode:
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