diff options
author | orwell96 <orwell@bleipb.de> | 2019-12-04 10:08:03 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2019-12-04 10:09:19 +0100 |
commit | 8d794525b3232dbe326043ee3d219ecabee04636 (patch) | |
tree | 21ceda1f78b5c943ade8309cd05d4eb6ec993530 | |
parent | e0662b2971e7d138fafff4ad709829656c8782e0 (diff) | |
download | advtrains-8d794525b3232dbe326043ee3d219ecabee04636.tar.gz advtrains-8d794525b3232dbe326043ee3d219ecabee04636.tar.bz2 advtrains-8d794525b3232dbe326043ee3d219ecabee04636.zip |
Fix repeated log file opening/closing (H#136)
-rw-r--r-- | advtrains/log.lua | 8 |
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 |