Log certain events in a logfile in the world directory
(also fix the output of /at_sync_ndb)master
parent
4c512f1dc5
commit
481f6218a8
|
@ -141,7 +141,8 @@ advtrains.meseconrules =
|
||||||
{x=0, y=1, z=-1},
|
{x=0, y=1, z=-1},
|
||||||
{x=0, y=-1, z=-1},
|
{x=0, y=-1, z=-1},
|
||||||
{x=0, y=-2, z=0}}
|
{x=0, y=-2, z=0}}
|
||||||
|
|
||||||
|
advtrains.fpath=minetest.get_worldpath().."/advtrains"
|
||||||
|
|
||||||
dofile(advtrains.modpath.."/path.lua")
|
dofile(advtrains.modpath.."/path.lua")
|
||||||
dofile(advtrains.modpath.."/trainlogic.lua")
|
dofile(advtrains.modpath.."/trainlogic.lua")
|
||||||
|
@ -160,13 +161,14 @@ dofile(advtrains.modpath.."/misc_nodes.lua")
|
||||||
dofile(advtrains.modpath.."/crafting.lua")
|
dofile(advtrains.modpath.."/crafting.lua")
|
||||||
dofile(advtrains.modpath.."/craft_items.lua")
|
dofile(advtrains.modpath.."/craft_items.lua")
|
||||||
|
|
||||||
|
dofile(advtrains.modpath.."/log.lua")
|
||||||
|
|
||||||
if minetest.global_exists("digtron") then
|
if minetest.global_exists("digtron") then
|
||||||
dofile(advtrains.modpath.."/digtron.lua")
|
dofile(advtrains.modpath.."/digtron.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
--load/save
|
--load/save
|
||||||
|
|
||||||
advtrains.fpath=minetest.get_worldpath().."/advtrains"
|
|
||||||
|
|
||||||
function advtrains.avt_load()
|
function advtrains.avt_load()
|
||||||
local file, err = io.open(advtrains.fpath, "r")
|
local file, err = io.open(advtrains.fpath, "r")
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
-- 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"
|
||||||
|
|
||||||
|
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
|
|
@ -256,7 +256,7 @@ ndb.restore_all = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local text="Restore node database: Replaced",cnt,"nodes, removed",dcnt,"ghost nodes"
|
local text="Restore node database: Replaced"..cnt.."nodes, removed"..dcnt.."ghost nodes."
|
||||||
atlog(text)
|
atlog(text)
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,4 +5,8 @@ advtrains_disable_collisions (Disable train collisions) bool false
|
||||||
# Enable the debug ring buffer
|
# Enable the debug ring buffer
|
||||||
# This has no effect on the user experience, except decreased performance. Debug outputs are saved in a ring buffer to be printed when an error occurs.
|
# This has no effect on the user experience, except decreased performance. Debug outputs are saved in a ring buffer to be printed when an error occurs.
|
||||||
# You probably want to leave this setting set to false.
|
# You probably want to leave this setting set to false.
|
||||||
advtrains_enable_debugging (Enable debugging) bool false
|
advtrains_enable_debugging (Enable debugging) bool false
|
||||||
|
# Enable the logging of certain events related to advtrains
|
||||||
|
# Logs are saved in the world directory as advtrains.log
|
||||||
|
# This setting is useful for multiplayer servers
|
||||||
|
advtrains_enable_logging (Enable logging) bool false
|
||||||
|
|
|
@ -311,6 +311,7 @@ function advtrains.register_tracks(tracktype, def, preset)
|
||||||
ndef.on_rightclick = function(pos, node, player)
|
ndef.on_rightclick = function(pos, node, player)
|
||||||
if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then
|
if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then
|
||||||
switchfunc(pos, node)
|
switchfunc(pos, node)
|
||||||
|
advtrains.log("Switch", player:get_player_name(), pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if var.switchmc then
|
if var.switchmc then
|
||||||
|
|
|
@ -1087,6 +1087,9 @@ function wagon:check_seat_group_access(pname, sgr)
|
||||||
if self.seat_groups[sgr].driving_ctrl_access and not (minetest.check_player_privs(pname, "train_operator") or self.owner==pname) then
|
if self.seat_groups[sgr].driving_ctrl_access and not (minetest.check_player_privs(pname, "train_operator") or self.owner==pname) then
|
||||||
return false, "Missing train_operator privilege."
|
return false, "Missing train_operator privilege."
|
||||||
end
|
end
|
||||||
|
if self.seat_groups[sgr].driving_ctrl_access then
|
||||||
|
advtrains.log("Drive", pname, self.object:getpos(), self:train().text_outside)
|
||||||
|
end
|
||||||
if not self.seat_access then
|
if not self.seat_access then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -1120,7 +1123,8 @@ function wagon:safe_decouple(pname)
|
||||||
minetest.chat_send_player(pname, "Couple is locked (ask owner or admin to unlock it)")
|
minetest.chat_send_player(pname, "Couple is locked (ask owner or admin to unlock it)")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
atprint("wagon:discouple() Splitting train", selftrain_id)
|
atprint("wagon:discouple() Splitting train", self.train_id)
|
||||||
|
advtrains.log("Discouple", pname, self.object:getpos(), self:train().text_outside)
|
||||||
advtrains.split_train_at_wagon(self)--found in trainlogic.lua
|
advtrains.split_train_at_wagon(self)--found in trainlogic.lua
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue