diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-03-22 15:10:38 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-03-22 15:10:38 +0000 |
commit | 059b6456a7e5dab6cacb002b6ddddb2338f79438 (patch) | |
tree | cb143d74012720c770a76133edc1516b042b68ce /util/debug.lua | |
parent | 4c94b7dbf1148040551c000f0fa5cf31713f1fc2 (diff) | |
download | prosody-059b6456a7e5dab6cacb002b6ddddb2338f79438.tar.gz prosody-059b6456a7e5dab6cacb002b6ddddb2338f79438.zip |
util.debug: Move optimal line length (default 65) into a variable
Diffstat (limited to 'util/debug.lua')
-rw-r--r-- | util/debug.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/util/debug.lua b/util/debug.lua index 6df249c0..9b1c4853 100644 --- a/util/debug.lua +++ b/util/debug.lua @@ -7,6 +7,8 @@ local censored_names = { pass = true; pwd = true; }; +local optimal_line_length = 65; + local function get_locals_table(level) level = level + 1; -- Skip this function itself @@ -139,7 +141,7 @@ function debug._traceback(thread, message, level) end if source_desc ~= last_source_desc then -- Venturing into a new source, add marker for previous if last_source_desc then - local padding = string.rep("-", math.floor(((65 - 6) - #last_source_desc)/2)); + local padding = string.rep("-", math.floor(((optimal_line_length - 6) - #last_source_desc)/2)); table.insert(lines, "\t ^"..padding.." "..last_source_desc.." "..padding..(#last_source_desc%2==0 and "-^" or "^ ")); end last_source_desc = source_desc; @@ -147,17 +149,17 @@ function debug._traceback(thread, message, level) nlevel = nlevel-1; table.insert(lines, "\t"..(nlevel==0 and ">" or " ").."("..nlevel..") "..line); local npadding = (" "):rep(#tostring(nlevel)); - local locals_str = string_from_var_table(level.locals, 65, "\t "..npadding); + local locals_str = string_from_var_table(level.locals, optimal_line_length, "\t "..npadding); if locals_str then table.insert(lines, "\t "..npadding.."Locals: "..locals_str); end - local upvalues_str = string_from_var_table(level.upvalues, 65, "\t "..npadding); + local upvalues_str = string_from_var_table(level.upvalues, optimal_line_length, "\t "..npadding); if upvalues_str then table.insert(lines, "\t "..npadding.."Upvals: "..upvalues_str); end end - local padding = string.rep("-", math.floor(((65 - 6) - #last_source_desc) / 2)); + local padding = string.rep("-", math.floor(((optimal_line_length - 6) - #last_source_desc) / 2)); table.insert(lines, "\t ^"..padding.." "..last_source_desc.." "..padding..(#last_source_desc%2==0 and "-^" or "^ ")); return message.."stack traceback:\n"..table.concat(lines, "\n"); |