Improve log messages (#422)
- Add log messages wherever required/useful - Remove unnecessary log messages and print statements - Convert print statements to minetest.log - Fix incorrect log level for some messages - Trivial code-style fixes
This commit is contained in:
parent
21e7daa183
commit
5eb5d3311a
18 changed files with 71 additions and 49 deletions
|
@ -15,7 +15,7 @@ globals = {
|
|||
"crafting", "vector", "table", "minetest", "worldedit", "ctf", "ctf_flag",
|
||||
"ctf_colors", "hudkit", "default", "treasurer", "ChatCmdBuilder", "ctf_map",
|
||||
"ctf_match", "ctf_stats", "ctf_treasure", "ctf_playertag", "chatplus", "irc",
|
||||
"armor",
|
||||
"armor", "vote", "give_initial_stuff"
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
|
|
|
@ -50,8 +50,6 @@ function ctf_alloc.set_all()
|
|||
return a.score > b.score
|
||||
end)
|
||||
|
||||
minetest.log("warning", dump(players))
|
||||
|
||||
local to_red = math.random(2) == 2
|
||||
for _, spair in pairs(players) do
|
||||
local player = spair.player
|
||||
|
|
|
@ -99,6 +99,7 @@ ctf.register_on_killedplayer(function(victim, killer)
|
|||
bountied_player = nil
|
||||
|
||||
local msg = killer .. " has killed " .. victim .. " and received the prize!"
|
||||
minetest.log("action", msg)
|
||||
minetest.chat_send_all(msg)
|
||||
hud_score.new(killer, {
|
||||
name = "ctf_bounty:prize",
|
||||
|
@ -118,6 +119,7 @@ minetest.register_chatcommand("place_bounty", {
|
|||
end
|
||||
|
||||
bounty_player(target)
|
||||
minetest.log("action", name .. " places bounty on " .. target)
|
||||
return true, "Put bounty on " .. target
|
||||
end
|
||||
})
|
||||
|
|
|
@ -114,7 +114,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
minp.y = center.y - h / 2
|
||||
maxp.y = center.y + h / 2
|
||||
|
||||
print("Loading data into LVM")
|
||||
minetest.log("action", "Map maker: Loading data into LVM")
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local emin, emax = vm:read_from_map(minp, maxp)
|
||||
|
@ -124,7 +124,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
}
|
||||
local data = vm:get_data()
|
||||
|
||||
print("Placing left wall")
|
||||
minetest.log("action", "Map maker: Placing left wall")
|
||||
|
||||
-- Left
|
||||
do
|
||||
|
@ -141,7 +141,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing right wall")
|
||||
minetest.log("action", "Map maker: Placing right wall")
|
||||
|
||||
-- Right
|
||||
do
|
||||
|
@ -158,7 +158,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing front wall")
|
||||
minetest.log("action", "Map maker: Placing front wall")
|
||||
|
||||
-- Front
|
||||
do
|
||||
|
@ -175,7 +175,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing back wall")
|
||||
minetest.log("action", "Map maker: Placing back wall")
|
||||
|
||||
-- Back
|
||||
do
|
||||
|
@ -192,7 +192,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing bedrock")
|
||||
minetest.log("action", "Map maker: Placing bedrock")
|
||||
|
||||
-- Bedrock
|
||||
do
|
||||
|
@ -204,7 +204,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Placing ceiling")
|
||||
minetest.log("action", "Map maker: Placing ceiling")
|
||||
|
||||
-- Ceiling
|
||||
do
|
||||
|
@ -216,7 +216,7 @@ function ctf_map.place_outer_barrier(center, r, h)
|
|||
end
|
||||
end
|
||||
|
||||
print("Writing to engine!")
|
||||
minetest.log("action", "Map maker: Writing to engine!")
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
|
|
|
@ -152,6 +152,7 @@ minetest.register_chatcommand("maps", {
|
|||
send_irc_catalog(name, idx or 1)
|
||||
end
|
||||
|
||||
minetest.log("action", name .. " views the map catalog")
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
|
|
@ -72,6 +72,7 @@ minetest.register_chatcommand("set_next", {
|
|||
local idx, map = ctf_map.get_idx_and_map(param)
|
||||
if idx then
|
||||
next_idx = idx
|
||||
minetest.log("action", name .. " selected '" .. map.name .. "' as next map")
|
||||
return true, "Selected " .. map.name
|
||||
else
|
||||
return false, "Couldn't find any matches"
|
||||
|
@ -80,7 +81,7 @@ minetest.register_chatcommand("set_next", {
|
|||
})
|
||||
|
||||
local function load_map_meta(idx, path)
|
||||
print("load_map_meta: Loading map meta from \"" .. path .. "\"")
|
||||
minetest.log("info", "load_map_meta: Loading map meta from \"" .. path .. "\"")
|
||||
local conf_path = mapdir .. path .. ".conf"
|
||||
local offset = vector.new(600 * idx, 0, 0)
|
||||
local meta = Settings(conf_path)
|
||||
|
@ -137,6 +138,7 @@ local function load_map_meta(idx, path)
|
|||
|
||||
-- Read custom chest zones from config
|
||||
i = 1
|
||||
minetest.log("info", "Parsing chest zones of " .. map.name .. "...")
|
||||
while meta:get("chests." .. i .. ".from") do
|
||||
local from = minetest.string_to_pos(meta:get("chests." .. i .. ".from"))
|
||||
local to = minetest.string_to_pos(meta:get("chests." .. i .. ".to"))
|
||||
|
@ -149,7 +151,7 @@ local function load_map_meta(idx, path)
|
|||
n = tonumber(meta:get("chests." .. i .. ".n") or "23"),
|
||||
}
|
||||
|
||||
minetest.log("warning", dump(map.chests[i]))
|
||||
minetest.log("info", dump(map.chests[i]))
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
|
@ -252,7 +254,7 @@ local function place_map(map)
|
|||
|
||||
local seed = minetest.get_mapgen_setting("seed")
|
||||
for _, chestzone in pairs(ctf_map.map.chests) do
|
||||
minetest.log("warning", "Placing " .. chestzone.n .. " chests from " ..
|
||||
minetest.log("info", "Placing " .. chestzone.n .. " chests from " ..
|
||||
minetest.pos_to_string(chestzone.from) .. " to "..
|
||||
minetest.pos_to_string(chestzone.to))
|
||||
place_chests(chestzone.from, chestzone.to, seed, chestzone.n)
|
||||
|
@ -340,7 +342,7 @@ ctf_match.register_on_new_match(function()
|
|||
end
|
||||
|
||||
if is_valid then
|
||||
minetest.log("info",
|
||||
minetest.log("action",
|
||||
"ctf_map: Registering treasure - " .. def[1])
|
||||
treasurer.register_treasure(def[1], def[2], def[3], def[4])
|
||||
end
|
||||
|
@ -362,7 +364,7 @@ function ctf_match.create_teams()
|
|||
local flag = table.copy(value.pos)
|
||||
|
||||
if name and color and flag then
|
||||
print(" - creating " .. key)
|
||||
minetest.log("action", "Creating team " .. key)
|
||||
ctf.team({
|
||||
name = name,
|
||||
color = color,
|
||||
|
@ -375,7 +377,7 @@ function ctf_match.create_teams()
|
|||
ctf_flag.assert_flag(flag)
|
||||
end)
|
||||
else
|
||||
minetest.log("error", " - Failed to create " .. key)
|
||||
minetest.log("error", "Failed to create team " .. key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,6 +47,8 @@ local function add_marker(name, tname, pos, str)
|
|||
world_pos = pos
|
||||
})
|
||||
end
|
||||
minetest.log("action", name .. " placed a marker at " ..
|
||||
minetest.pos_to_string(pos) .. ": '" .. str .. "'")
|
||||
minetest.chat_send_player(pname,
|
||||
msg("Player " .. name .. " placed a marker!"))
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ minetest.register_chatcommand("ctf_next", {
|
|||
},
|
||||
func = function(name, param)
|
||||
ctf_match.next()
|
||||
minetest.log("action", name .. " ran /ctf_next")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -19,6 +20,7 @@ minetest.register_chatcommand("ctf_start", {
|
|||
},
|
||||
func = function(name, param)
|
||||
ctf_match.build_timer = 0.01
|
||||
minetest.log("action", name .. " ran /ctf_start")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -58,6 +60,7 @@ minetest.register_chatcommand("ctf_queue_restart", {
|
|||
func = function(name, param)
|
||||
restart_on_next_match = true
|
||||
restart_on_next_match_by = name
|
||||
minetest.log("action", name .. " queued a restart")
|
||||
return true, "Restart queued."
|
||||
end
|
||||
})
|
||||
|
@ -69,6 +72,7 @@ minetest.register_chatcommand("ctf_unqueue_restart", {
|
|||
},
|
||||
func = function(name, param)
|
||||
restart_on_next_match = false
|
||||
minetest.log("action", name .. " un-queued a restart")
|
||||
return true, "Restart cancelled."
|
||||
end
|
||||
})
|
||||
|
|
|
@ -54,7 +54,6 @@ local function update(player, settings)
|
|||
|
||||
if settings.type == TYPE_BUILTIN then
|
||||
remove_entity_tag(player)
|
||||
print(dump(settings.color))
|
||||
player:set_nametag_attributes({
|
||||
color = settings.color
|
||||
})
|
||||
|
|
|
@ -287,11 +287,13 @@ minetest.register_chatcommand("r", {
|
|||
param = param:trim()
|
||||
if ctf_stats.players[param] then
|
||||
target = param
|
||||
minetest.log("action", name .. " ran /r " .. param)
|
||||
else
|
||||
return false, "Can't find player '" .. param .. "'"
|
||||
end
|
||||
else
|
||||
target = name
|
||||
minetest.log("action", name .. " ran /r")
|
||||
end
|
||||
return return_as_chat_result(name, target)
|
||||
end
|
||||
|
@ -306,11 +308,13 @@ minetest.register_chatcommand("rankings", {
|
|||
param = param:trim()
|
||||
if ctf_stats.players[param] then
|
||||
target = param
|
||||
minetest.log("action", name .. " ran /rankings " .. param)
|
||||
else
|
||||
return false, "Can't find player '" .. param .. "'"
|
||||
end
|
||||
else
|
||||
target = name
|
||||
minetest.log("action", name .. " ran /rankings")
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(name) then
|
||||
|
@ -359,6 +363,13 @@ minetest.register_chatcommand("reset_rankings", {
|
|||
|
||||
ctf_stats.players[reset_name] = nil
|
||||
ctf_stats.player(reset_name)
|
||||
|
||||
if reset_name == name then
|
||||
minetest.log("action", name .. " reset their rankings")
|
||||
else
|
||||
minetest.log("action", name .. " reset rankings of " .. reset_name)
|
||||
end
|
||||
|
||||
return true, "Successfully reset the stats and ranking of " .. reset_name
|
||||
end
|
||||
})
|
||||
|
@ -386,6 +397,7 @@ minetest.register_chatcommand("transfer_rankings", {
|
|||
ctf_stats.players[dest] = ctf_stats.players[src]
|
||||
ctf_stats.players[src] = nil
|
||||
|
||||
minetest.log("action", name .. " transferred stats of " .. src .. " to " .. dest)
|
||||
return true, "Stats of '" .. src .. "' have been transferred to '" .. dest .. "'."
|
||||
end
|
||||
})
|
||||
|
|
|
@ -350,6 +350,7 @@ minetest.register_chatcommand("summary", {
|
|||
|
||||
fs = fs .. "button[6,7.5;4,1;b_prev;<< Previous match]"
|
||||
|
||||
minetest.log("action", name .. " requested match summary formspec")
|
||||
minetest.show_formspec(name, "ctf_stats:match_summary", fs)
|
||||
end
|
||||
})
|
||||
|
|
|
@ -3,6 +3,7 @@ minetest.register_chatcommand("killme", {
|
|||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
minetest.log("action", name .. " ran /killme")
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
player:set_hp(0)
|
||||
return true
|
||||
|
|
|
@ -11,6 +11,7 @@ local function add_irc_mod(name)
|
|||
end
|
||||
mods[#mods + 1] = name
|
||||
storage:set_string("irc_mods", table.concat(mods, ","))
|
||||
minetest.log("action", name .. " subscribed to IRC reports")
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -20,6 +21,7 @@ local function remove_irc_mod(name)
|
|||
if idx > 0 then
|
||||
table.remove(mods, idx)
|
||||
storage:set_string("irc_mods", table.concat(mods, ","))
|
||||
minetest.log("action", name .. " un-subscribed from IRC reports")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
@ -36,6 +38,7 @@ minetest.register_chatcommand("report_sub", {
|
|||
end
|
||||
else
|
||||
if add_irc_mod(name) then
|
||||
minetest.log("action", name .. " subscribed to IRC reports")
|
||||
return true, "Successfully added!"
|
||||
else
|
||||
return false, "Unable to add, are you already subscribed?"
|
||||
|
|
|
@ -203,14 +203,14 @@ function place_chests(minp, maxp, seed, number_chests)
|
|||
chest_pos.z = -1
|
||||
end
|
||||
|
||||
local nn = minetest.get_node(chest_pos).name -- chest node name (before it becomes a chest)
|
||||
-- chest node name (before it becomes a chest)
|
||||
local nn = minetest.get_node(chest_pos).name
|
||||
if nn == "air" or nn == "default:water_source" then
|
||||
placeChest(pos, chest_pos, ground, nn)
|
||||
|
||||
chests_placed = chests_placed + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.log("warning", "Spawned " .. chests_placed .. "/" .. number_chests .. " chests after " .. attempts .. " attempts!")
|
||||
minetest.log("info", "Spawned " .. chests_placed .. "/" .. number_chests .. " chests after " .. attempts .. " attempts!")
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ function vote.start_vote(voteset)
|
|||
if voteset.options then
|
||||
for _, option in pairs(voteset.options) do
|
||||
voteset.results[option] = {}
|
||||
print(" - " .. option)
|
||||
minetest.log("action", " - " .. option)
|
||||
end
|
||||
else
|
||||
voteset.results.yes = {}
|
||||
|
|
|
@ -2,19 +2,19 @@ vote.kick_cooldown = 600
|
|||
local vlist = {} -- table storing player name, ip & lock status
|
||||
|
||||
minetest.register_privilege("vote_kick", {
|
||||
description = "Can (start) vote to kick a player",
|
||||
description = "Can start vote to kick a player",
|
||||
on_grant = function(name, granter)
|
||||
if not granter then
|
||||
granter = "<nil>"
|
||||
end
|
||||
minetest.log("warning", "Player '" .. name .. "' has been" ..
|
||||
minetest.log("action", "Player '" .. name .. "' has been" ..
|
||||
" granted 'vote_kick' by '" .. granter .. "'")
|
||||
end,
|
||||
on_revoke = function(name, revoker)
|
||||
if not revoker then
|
||||
revoker = "<nil>"
|
||||
end
|
||||
minetest.log("warning", "Player '" .. name .. "' has been" ..
|
||||
minetest.log("action", "Player '" .. name .. "' has been" ..
|
||||
" revoked of 'vote_kick' by '" .. revoker .. "'")
|
||||
end
|
||||
})
|
||||
|
@ -33,17 +33,14 @@ minetest.register_chatcommand("vote_kick", {
|
|||
end
|
||||
|
||||
if not minetest.get_player_by_name(param) then
|
||||
return false, "There is no player called '" ..
|
||||
param .. "'"
|
||||
return false, "There is no player called '" .. param .. "'"
|
||||
end
|
||||
|
||||
if minetest.check_player_privs(param, {kick = true, ban = true}) then
|
||||
return false, param .. " is a moderator, and can't be kicked!"
|
||||
end
|
||||
|
||||
minetest.log("warning", "Player '" .. name .. "' started a vote" ..
|
||||
" to kick '" .. param .. "'")
|
||||
|
||||
minetest.log("action", name .. " started a vote to kick " .. param)
|
||||
|
||||
if not vlist[param] then
|
||||
vlist[param] = {
|
||||
|
@ -108,6 +105,7 @@ minetest.register_chatcommand("unblock", {
|
|||
end
|
||||
|
||||
vlist[param].locked = false
|
||||
minetest.log("action", name .. " unblocked " .. param .. ", who was vote-kicked")
|
||||
return true, param .. " has been successfully unblocked!"
|
||||
end
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ local function drop(pos, itemstack)
|
|||
|
||||
for _, item in pairs(blacklist_drop) do
|
||||
if sname == item then
|
||||
minetest.log("info", "Not dropping " .. item)
|
||||
minetest.log("info", "[dropondie] Not dropping " .. sname)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -20,7 +20,6 @@ local function drop(pos, itemstack)
|
|||
if minetest.is_yes(remi) then
|
||||
obj:remove()
|
||||
end
|
||||
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
|
|
@ -22,13 +22,13 @@ end
|
|||
function hp_bar:on_step(dtime)
|
||||
local wielder = self.wielder and minetest.get_player_by_name(self.wielder)
|
||||
if wielder == nil then
|
||||
print("[gauges] Gauge removed as null wielder! " .. dump(self.wielder))
|
||||
minetest.log("warning", "[gauges] Gauge removed as null wielder! " .. dump(self.wielder))
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
if vector.sqdist(wielder:get_pos(), self.object:get_pos()) > 3 then
|
||||
print("[gauges] Gauge removed as not attached! " .. dump(self.wielder))
|
||||
minetest.log("warning", "[gauges] Gauge removed as not attached! " .. dump(self.wielder))
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
@ -80,7 +80,7 @@ function gauges.check_gauges()
|
|||
end
|
||||
|
||||
if not found then
|
||||
print("Gauge not found!")
|
||||
minetest.log("warning", "[gauges] Gauge not found for player " .. pname)
|
||||
gauges.add_HP_gauge(pname)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue