aboutsummaryrefslogtreecommitdiff
path: root/advtrains/log.lua
blob: d7053a2d6ec8680ae1289d881f02509c3b2bffe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- Log accesses to driver stands and changes to switches

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)
	   log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n")
	end
	
	minetest.register_on_shutdown(function()
		log:close()
	end)
end