Changed lume.trace() to output in a nicer format, updated test

This commit is contained in:
rxi 2015-08-14 20:27:31 +01:00
parent d8027db54d
commit 78144dbdb8
2 changed files with 3 additions and 3 deletions

View File

@ -618,11 +618,11 @@ end
function lume.trace(...)
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
local x = select(i, ...)
if type(x) == "number" then
x = string.format("%g", lume.round(x, .01))
x = tonumber(lume.round(x, .01))
end
t[#t + 1] = tostring(x)
end

View File

@ -535,7 +535,7 @@ tests["lume.trace"] = function()
local oldprint = print
local file, line, msg
print = function(x)
file, line, msg = x:match("%[(.-):(.-)%] (.*)")
file, line, msg = x:match("(.-):(.-): (.*)")
end
lume.trace("Hi world", 123.456, 1, nil)
print = oldprint