aboutsummaryrefslogtreecommitdiffstats
path: root/util/debug.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-24 18:53:50 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-24 18:53:50 +0100
commit97f896be36bb265ae0bae619e6e580b88bc704bd (patch)
tree53c416dc4518c94d62614624e2c54c69e9f64925 /util/debug.lua
parent6f6e05cf7436075c999eee0e5165795311a25406 (diff)
downloadprosody-97f896be36bb265ae0bae619e6e580b88bc704bd.tar.gz
prosody-97f896be36bb265ae0bae619e6e580b88bc704bd.zip
util.debug: Turn into a real-ish module ('debugx'), and require you call use() to override debug.traceback()
Diffstat (limited to 'util/debug.lua')
-rw-r--r--util/debug.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/util/debug.lua b/util/debug.lua
index 2170a6d1..aeb710d7 100644
--- a/util/debug.lua
+++ b/util/debug.lua
@@ -8,7 +8,9 @@ local censored_names = {
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 @@ local function get_locals_table(level)
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 @@ local function get_upvalues_table(func)
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 @@ function get_traceback_table(thread, start_level)
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 @@ function debug.traceback(thread, message, level)
end
return message.."stack traceback:\n"..table.concat(lines, "\n");
end
+
+function use()
+ debug.traceback = traceback;
+end
+
+return _M;