aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/log.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/advtrains/log.lua b/advtrains/log.lua
index d2b71d3..d7053a2 100644
--- a/advtrains/log.lua
+++ b/advtrains/log.lua
@@ -5,9 +5,13 @@ 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)
- 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
+
+ minetest.register_on_shutdown(function()
+ log:close()
+ end)
end