Add a chat command to write to the log
This commit is contained in:
parent
3260c78125
commit
5009244783
@ -1,8 +1,8 @@
|
|||||||
-- LUALOCALS < ---------------------------------------------------------
|
-- LUALOCALS < ---------------------------------------------------------
|
||||||
local minetest, string
|
local ipairs, minetest, string, table
|
||||||
= minetest, string
|
= ipairs, minetest, string, table
|
||||||
local string_format
|
local string_format, table_concat, table_remove
|
||||||
= string.format
|
= string.format, table.concat, table.remove
|
||||||
-- LUALOCALS > ---------------------------------------------------------
|
-- LUALOCALS > ---------------------------------------------------------
|
||||||
|
|
||||||
-- Chat command to completely destroy a player account, including auth.
|
-- Chat command to completely destroy a player account, including auth.
|
||||||
@ -29,6 +29,29 @@ minetest.register_chatcommand("destroy_player", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Chat command to write to the server log.
|
||||||
|
do
|
||||||
|
local allowed = {"verbose", "info", "action", "warning", "error"}
|
||||||
|
local allowed_idx = {}
|
||||||
|
for _, v in ipairs(allowed) do allowed_idx[v] = true end
|
||||||
|
local allowed_str = table_concat(allowed, ", ")
|
||||||
|
minetest.register_chatcommand("log", {
|
||||||
|
params = "<severity> <message>",
|
||||||
|
description = "Write any message to server log",
|
||||||
|
privs = {server = true},
|
||||||
|
func = function(name, param)
|
||||||
|
local words = param:split(" ")
|
||||||
|
local severity = words[1]
|
||||||
|
table_remove(words, 1)
|
||||||
|
if not allowed_idx[severity] then
|
||||||
|
return false, "severity must be one of " .. allowed_str
|
||||||
|
end
|
||||||
|
minetest.log("action", name .. " used the log command")
|
||||||
|
minetest.log(severity, table_concat(words, " "))
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- Moderators and admins can always bypass player limits,
|
-- Moderators and admins can always bypass player limits,
|
||||||
-- important for emergency access.
|
-- important for emergency access.
|
||||||
minetest.register_can_bypass_userlimit(function(name)
|
minetest.register_can_bypass_userlimit(function(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user