Add Druid logger

This commit is contained in:
Insality
2025-10-27 22:25:37 +02:00
parent c43356d743
commit 2a169da3af
3 changed files with 90 additions and 9 deletions

View File

@@ -404,24 +404,44 @@ function M.is_multitouch_supported()
end
---Simple table to one-line string converter
---Converts table to one-line string
---@param t table
---@return string
function M.table_to_string(t)
if not t then
return ""
---@param depth number?
---@param result string|nil Internal parameter
---@return string, boolean result String representation of table, Is max string length reached
function M.table_to_string(t, depth, result)
if type(t) ~= "table" then
return tostring(t) or "", false
end
local result = "{"
depth = depth or 0
result = result or "{"
for key, value in pairs(t) do
if #result > 1 then
result = result .. ","
result = result .. ", "
end
if type(value) == "table" then
if depth == 0 then
local table_len = 0
for _ in pairs(value) do
table_len = table_len + 1
end
result = result .. key .. ": {... #" .. table_len .. "}"
else
local convert_result, is_limit = M.table_to_string(value, depth - 1, "")
result = result .. key .. ": {" .. convert_result
if is_limit then
break
end
end
else
result = result .. key .. ": " .. tostring(value)
end
result = result .. key .. ": " .. value
end
return result .. "}"
return result .. "}", false
end