aboutsummaryrefslogtreecommitdiff
path: root/advtrains/log.lua
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-02-22 11:03:53 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-02-22 11:03:53 +0100
commit8ca7325d7ce7b0ce141cea7c607e586654343f86 (patch)
treee207cec22ea50d1362b97b8ba964392d2d9e8bcd /advtrains/log.lua
parent81d637dc76317df249a4d290006975141ab1a605 (diff)
parent481f6218a8b377a0826b7e080046b5a890702e12 (diff)
downloadadvtrains-8ca7325d7ce7b0ce141cea7c607e586654343f86.tar.gz
advtrains-8ca7325d7ce7b0ce141cea7c607e586654343f86.tar.bz2
advtrains-8ca7325d7ce7b0ce141cea7c607e586654343f86.zip
Merge https://github.com/orwell96/advtrains into log
Diffstat (limited to 'advtrains/log.lua')
-rw-r--r--advtrains/log.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/advtrains/log.lua b/advtrains/log.lua
index 827948f..d2b71d3 100644
--- a/advtrains/log.lua
+++ b/advtrains/log.lua
@@ -1,9 +1,13 @@
-- Log accesses to driver stands and changes to switches
-advtrains.logfile = advtrains.fpath .. "_log"
+advtrains.log = function() end
-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()
+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+")
+ log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n")
+ log:close()
+ end
end