# HG changeset patch # User Matthew Wild # Date 1335290030 -3600 # Node ID 8834f220ab91e49de118bac2c0bc47a35bb22202 # Parent 5b52b5eaa03d30cb9445a3ed847364341ba644f5 util.debug: Turn into a real-ish module ('debugx'), and require you call use() to override debug.traceback() diff -r 5b52b5eaa03d -r 8834f220ab91 util/debug.lua --- a/util/debug.lua Tue Apr 24 18:50:22 2012 +0100 +++ b/util/debug.lua Tue Apr 24 18:53:50 2012 +0100 @@ -8,7 +8,9 @@ pwd = true; }; -local function get_locals_table(level) +module("debugx", package.seeall); + +function get_locals_table(level) level = level + 1; -- Skip this function itself local locals = {}; for local_num = 1, math.huge do @@ -19,7 +21,7 @@ return locals; end -local function get_upvalues_table(func) +function get_upvalues_table(func) local upvalues = {}; if func then for upvalue_num = 1, math.huge do @@ -31,7 +33,7 @@ return upvalues; end -local function string_from_var_table(var_table, max_line_len, indent_str) +function string_from_var_table(var_table, max_line_len, indent_str) local var_string = {}; local col_pos = 0; max_line_len = max_line_len or math.huge; @@ -88,7 +90,7 @@ return levels; end -function debug.traceback(thread, message, level) +function traceback(thread, message, level) if type(thread) ~= "thread" then thread, message, level = coroutine.running(), thread, message; end @@ -136,3 +138,9 @@ end return message.."stack traceback:\n"..table.concat(lines, "\n"); end + +function use() + debug.traceback = traceback; +end + +return _M;