-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lua-resty-auto-ssl-storage-adapter-consul (#25): debug helpers, more …
…centralzed this time (not really need in the end product, but I need to inspect lua things without killing openresty
- Loading branch information
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
doc | ||
doc | ||
|
||
DataDumper.lua | ||
# ansible -m copy -a "src=./DataDumper.lua dest=/usr/local/share/lua/5.1/resty/auto-ssl/storage_adapters/DataDumper.lua" aguia-pescadora-delta.etica.ai,aguia-pescadora-echo.etica.ai,aguia-pescadora-foxtrot.etica.ai | ||
# ansible -m copy -a "src=./debughelpers.lua dest=/usr/local/share/lua/5.1/resty/auto-ssl/storage_adapters/debughelpers.lua" aguia-pescadora-delta.etica.ai,aguia-pescadora-echo.etica.ai,aguia-pescadora-foxtrot.etica.ai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-- https://pastebin.com/A7JScXWk | ||
function dumpvar(data) | ||
-- cache of tables already printed, to avoid infinite recursive loops | ||
local tablecache = {} | ||
local buffer = "" | ||
local padder = " " | ||
|
||
local function _dumpvar(d, depth) | ||
local t = type(d) | ||
local str = tostring(d) | ||
if (t == "table") then | ||
if (tablecache[str]) then | ||
-- table already dumped before, so we dont | ||
-- dump it again, just mention it | ||
buffer = buffer.."<"..str..">\n" | ||
else | ||
tablecache[str] = (tablecache[str] or 0) + 1 | ||
buffer = buffer.."("..str..") {\n" | ||
for k, v in pairs(d) do | ||
buffer = buffer..string.rep(padder, depth+1).."["..k.."] => " | ||
_dumpvar(v, depth+1) | ||
end | ||
buffer = buffer..string.rep(padder, depth).."}\n" | ||
end | ||
elseif (t == "number") then | ||
buffer = buffer.."("..t..") "..str.."\n" | ||
else | ||
buffer = buffer.."("..t..") \""..str.."\"\n" | ||
end | ||
end | ||
_dumpvar(data, 0) | ||
return buffer | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters