diff options
Diffstat (limited to 'advtrains/log.lua')
-rw-r--r-- | advtrains/log.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/advtrains/log.lua b/advtrains/log.lua new file mode 100644 index 0000000..d7053a2 --- /dev/null +++ b/advtrains/log.lua @@ -0,0 +1,17 @@ +-- 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" + + local log = io.open(advtrains.logfile, "a+") + + function advtrains.log (event, player, pos, data) + log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n") + end + + minetest.register_on_shutdown(function() + log:close() + end) +end |