Fix repeated log file opening/closing (H#136)

This commit is contained in:
orwell96 2019-12-04 10:08:03 +01:00
parent e0662b2971
commit 8d794525b3
1 changed files with 6 additions and 2 deletions

View File

@ -5,9 +5,13 @@ 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+")
function advtrains.log (event, player, pos, data)
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