Configurable inventory log level (#17)

This aims to reduce spammed log files and corrects nonsense translations to the terminal
This commit is contained in:
SmallJoker 2022-07-10 20:25:16 +02:00 committed by GitHub
parent a05aa9a59b
commit c691f370b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 18 deletions

@ -15,3 +15,5 @@ hopper.config.eject_button_enabled = minetest.settings:get_bool("hopper_eject_bu
if hopper.config.eject_button_enabled == nil then if hopper.config.eject_button_enabled == nil then
hopper.config.eject_button_enabled = true hopper.config.eject_button_enabled = true
end end
hopper.config.inv_log_level = minetest.settings:get("hopper_inventory_log_level") or "info"

@ -62,4 +62,10 @@ if minetest.get_modpath("lucky_block") then
}) })
end end
-- Utility function for inventory movement logs
function hopper.log_inventory(...)
minetest.log(hopper.config.inv_log_level, ...)
end
minetest.log("action", "[hopper] Hopper mod loaded") minetest.log("action", "[hopper] Hopper mod loaded")

@ -75,7 +75,7 @@ minetest.register_node("hopper:chute", {
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff to chute at @2", hopper.log_inventory(("%s moves stuff to chute at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
local timer = minetest.get_node_timer(pos) local timer = minetest.get_node_timer(pos)

@ -121,17 +121,17 @@ minetest.register_node("hopper:hopper", {
end, end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", S("@1 moves stuff in hopper at @2", minetest.log("action", ("%s moves stuff in hopper at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff to hopper at @2", hopper.log_inventory(("%s moves stuff to hopper at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
end, end,
on_metadata_inventory_take = function(pos, listname, index, stack, player) on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff from hopper at @2", hopper.log_inventory(("%s moves stuff from hopper at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
end, end,
}) })
@ -214,17 +214,18 @@ minetest.register_node("hopper:hopper_side", {
end, end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", S("@1 moves stuff in hopper at @2", -- Only players move items. "action" is generally okay here.
minetest.log("action", ("%s moves stuff in hopper at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff to hopper at @2", hopper.log_inventory(("%s moves stuff to hopper at%s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
end, end,
on_metadata_inventory_take = function(pos, listname, index, stack, player) on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff from hopper at @2", hopper.log_inventory(("%s moves stuff from hopper at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
end, end,
}) })

@ -141,7 +141,7 @@ minetest.register_node("hopper:sorter", {
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff to sorter at @2", hopper.log_inventory(("%s moves stuff to sorter at %s"):format(
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))
local timer = minetest.get_node_timer(pos) local timer = minetest.get_node_timer(pos)

@ -12,3 +12,6 @@ hopper_single_craftable_item (Single craftable item) bool true
# in their target location to receive them. By default hoppers do not eject # in their target location to receive them. By default hoppers do not eject
# items like this, the player must set this on a per-hopper basis. # items like this, the player must set this on a per-hopper basis.
hopper_eject_button (Eject items button) bool true hopper_eject_button (Eject items button) bool true
# The Minetest log level to use for inventory take/put actions
hopper_inventory_log_level (Inventory log level) enum action none,action,info,verbose