local mt = getmetatable(_G) or
local function print(val) if type(val)
"string" then return '"' .. val .. '"' else return tostring(val) endend
mt.__newindex = function (self, key, value) if key ~= "arg" then mw.log("Global variable " .. print(key) .. " was set to " .. print(value) .. " somewhere:", debug.traceback("", 2)) end return rawset(self, key, value)end
mt.__index = function (self, key) if key ~= "arg" then mw.log("Nil global variable " .. print(key) .. " was read somewhere:", debug.traceback("", 2)) end return rawget(self, key)end
setmetatable(_G, mt)