Module:log set and get

Hello, you have come here looking for the meaning of the word Module:log set and get. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:log set and get, but we will also tell you about its etymology, its characteristics and you will know how to say Module:log set and get in singular and plural. Everything you need to know about the word Module:log set and get you have here. The definition of the word Module:log set and get will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:log set and get, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

Creates a new version of a table that prints setting (__newindex) and getting (__index) operations to the log, that is table = value and value = table. This can help you identify why a value in your table has vanished or appeared. May not work if the table already has a metatable.


-- unique keys
local inner_key = function() end
local name_key = function() end

local function write_key(self, k)
	return (rawget(self, name_key) or "") .. ""
end

local mt = {
	__newindex = function(self, k, v)
		mw.logObject(v, "setting " .. write_key(self, k))
		rawset(rawget(self, inner_key), k, v)
	end,
	__index = function(self, k)
		local v = rawget(rawget(self, inner_key), k)
		mw.logObject(v, "getting " .. write_key(self, k))
		return v
	end,
	__pairs = function(self)
		return pairs(self)
	end,
	__ipairs = function(self)
		return ipairs(self)
	end,
}

return function(t, name)
	return setmetatable({  = t,  = name }, mt)
end