mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Changed lume.trace() to output in a nicer format, updated test
This commit is contained in:
parent
d8027db54d
commit
78144dbdb8
4
lume.lua
4
lume.lua
@ -618,11 +618,11 @@ end
|
|||||||
|
|
||||||
function lume.trace(...)
|
function lume.trace(...)
|
||||||
local info = debug.getinfo(2, "Sl")
|
local info = debug.getinfo(2, "Sl")
|
||||||
local t = { "[" .. info.short_src .. ":" .. info.currentline .. "]" }
|
local t = { info.short_src .. ":" .. info.currentline .. ":" }
|
||||||
for i = 1, select("#", ...) do
|
for i = 1, select("#", ...) do
|
||||||
local x = select(i, ...)
|
local x = select(i, ...)
|
||||||
if type(x) == "number" then
|
if type(x) == "number" then
|
||||||
x = string.format("%g", lume.round(x, .01))
|
x = tonumber(lume.round(x, .01))
|
||||||
end
|
end
|
||||||
t[#t + 1] = tostring(x)
|
t[#t + 1] = tostring(x)
|
||||||
end
|
end
|
||||||
|
@ -535,7 +535,7 @@ tests["lume.trace"] = function()
|
|||||||
local oldprint = print
|
local oldprint = print
|
||||||
local file, line, msg
|
local file, line, msg
|
||||||
print = function(x)
|
print = function(x)
|
||||||
file, line, msg = x:match("%[(.-):(.-)%] (.*)")
|
file, line, msg = x:match("(.-):(.-): (.*)")
|
||||||
end
|
end
|
||||||
lume.trace("Hi world", 123.456, 1, nil)
|
lume.trace("Hi world", 123.456, 1, nil)
|
||||||
print = oldprint
|
print = oldprint
|
||||||
|
Loading…
Reference in New Issue
Block a user