mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-12-13 17:24:21 +00:00
Fixed lume.trace() to handle and print nil
argument
This commit is contained in:
parent
09847bd266
commit
8a2765a41b
13
lume.lua
13
lume.lua
@ -34,6 +34,7 @@ local iscallable = function(x)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function lume.clamp(x, min, max)
|
function lume.clamp(x, min, max)
|
||||||
return x < min and min or (x > max and max or x)
|
return x < min and min or (x > max and max or x)
|
||||||
end
|
end
|
||||||
@ -344,13 +345,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function lume.trace(...)
|
function lume.trace(...)
|
||||||
local function stringify(x)
|
|
||||||
x = (type(x) == "number") and lume.round(x, .01) or x
|
|
||||||
return tostring(x)
|
|
||||||
end
|
|
||||||
local info = debug.getinfo(2, "Sl")
|
local info = debug.getinfo(2, "Sl")
|
||||||
local head = "[" .. info.short_src .. ":" .. info.currentline .. "] "
|
local t = { "[" .. info.short_src .. ":" .. info.currentline .. "]" }
|
||||||
print(head .. table.concat(lume.map({...}, stringify), " "))
|
for i = 1, select("#", ...) do
|
||||||
|
local x = select(i, ...)
|
||||||
|
t[#t + 1] = (type(x) == "number") and lume.round(x, .01) or (x or "nil")
|
||||||
|
end
|
||||||
|
print(table.concat(t, " "))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user