aboutsummaryrefslogtreecommitdiffstats
path: root/util/debug.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-24 21:59:20 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-24 21:59:20 +0100
commit8f062c3d98b1e3c6a5b56cdb5ad4ea0a326a513d (patch)
treefe8c013599dd847f7365cb1adab80ab8fe846de5 /util/debug.lua
parentfc3a3c0b0c3a37017bc500e58b8dbdd4b39627c9 (diff)
parentb23e6a2ef012c2d2568766ef0f41aaadf3cac826 (diff)
downloadprosody-8f062c3d98b1e3c6a5b56cdb5ad4ea0a326a513d.tar.gz
prosody-8f062c3d98b1e3c6a5b56cdb5ad4ea0a326a513d.zip
Merge timber->trunk - thanks everyone!
Diffstat (limited to 'util/debug.lua')
-rw-r--r--util/debug.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/util/debug.lua b/util/debug.lua
index 3736dd34..7caf21ce 100644
--- a/util/debug.lua
+++ b/util/debug.lua
@@ -22,8 +22,9 @@ do
location = _("yellow");
};
end
+module("debugx", package.seeall);
-local function get_locals_table(level)
+function get_locals_table(level)
level = level + 1; -- Skip this function itself
local locals = {};
for local_num = 1, math.huge do
@@ -34,7 +35,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
@@ -46,7 +47,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;
@@ -103,8 +104,8 @@ function get_traceback_table(thread, start_level)
return levels;
end
-function debug.traceback(...)
- local ok, ret = pcall(debug._traceback, ...);
+function traceback(...)
+ local ok, ret = pcall(_traceback, ...);
if not ok then
return "Error in error handling: "..ret;
end
@@ -116,7 +117,8 @@ local function build_source_boundary_marker(last_source_desc)
return getstring(styles.boundary_padding, "v"..padding).." "..getstring(styles.filename, last_source_desc).." "..getstring(styles.boundary_padding, padding..(#last_source_desc%2==0 and "-v" or "v "));
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
@@ -178,3 +180,9 @@ function debug._traceback(thread, message, level)
return message.."stack traceback:\n"..table.concat(lines, "\n");
end
+
+function use()
+ debug.traceback = traceback;
+end
+
+return _M;