Module:Debug: Difference between revisions
Jump to navigation
Jump to search
Mediawiki>Siroopwafel m (Seriously..) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 10: | Line 10: | ||
local p = {} | local p = {} | ||
local dumpObj = require(' | local dumpObj = require('Module:Inspect').inspect | ||
local frameTools = require(" | local frameTools = require("Module:FrameTools") | ||
-- e.g. {"abc","zz"} parameters from a page calling this module directly | -- e.g. {"abc","zz"} parameters from a page calling this module directly |
Latest revision as of 05:18, 2 May 2021
Documentation for this module may be created at Module:Debug/doc
--[[ //Helps debug lua modules using console by creating a pseudo frame and other useful functions Syntax: require("Module:debug").frame(childtable, parenttable) Example: frame = require("Module:debug").frame({'aaa','sss'},{'zz'=8,'1'}) p.main(frame) Todo: Add more debugging tools ]]-- local p = {} local dumpObj = require('Module:Inspect').inspect local frameTools = require("Module:FrameTools") -- e.g. {"abc","zz"} parameters from a page calling this module directly function p.frame(args, pArgs) return frameTools.makePseudoFrame({}, pArgs or {}, args or {}) end -- Generates a tracebackfor a function -- ex. function fFunction() x=1 +c end ; p.trace(fFunction, var1,var2) function p.trace(errFunction, ...) local function testFunc () return errFunction(unpack(arg)) end local success, result = xpcall(testFunc, function(err) mw.log(debug.traceback(err) ) return debug.traceback(err) end) return success, result end -- Outputs the information from a obj (readable table, string, number, etc) function p.log(obj) return dumpObj(obj) end return p