Fix repeated log file opening/closing (H#136)
This commit is contained in:
parent
e0662b2971
commit
8d794525b3
|
@ -5,9 +5,13 @@ advtrains.log = function() end
|
||||||
if minetest.settings:get_bool("advtrains_enable_logging") then
|
if minetest.settings:get_bool("advtrains_enable_logging") then
|
||||||
advtrains.logfile = advtrains.fpath .. "_log"
|
advtrains.logfile = advtrains.fpath .. "_log"
|
||||||
|
|
||||||
|
local log = io.open(advtrains.logfile, "a+")
|
||||||
|
|
||||||
function advtrains.log (event, player, pos, data)
|
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:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n")
|
||||||
log:close()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
log:close()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue