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 | 9749a46686265099965e0107a41544cea2a9709d (patch) | |
tree | cb143d74012720c770a76133edc1516b042b68ce /util | |
parent | b5ff9d70ddb8c214316f3b81abfb6567be8207d6 (diff) | |
download | prosody-9749a46686265099965e0107a41544cea2a9709d.tar.gz prosody-9749a46686265099965e0107a41544cea2a9709d.zip |
util.debug: Move optimal line length (default 65) into a variable
Diffstat (limited to 'util')
-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"); |