mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Added lume.trace() function
This commit is contained in:
parent
3324bb013c
commit
fbe585fc85
@ -198,6 +198,14 @@ lume.format("Hello {a}, I hope {a} is {b}.", {a = "world", b = "well"})
|
||||
-- Returns "Hello world, I hope world is well."
|
||||
```
|
||||
|
||||
### lume.trace(...)
|
||||
Prints the current filename and line number followed by each argument separated
|
||||
by a space.
|
||||
```lua
|
||||
-- Assuming the file is called "example.lua" and the next line is 12:
|
||||
lume.trace("hello", 1234) -- Prints "[example.lua:12] hello 1234"
|
||||
```
|
||||
|
||||
### lume.dostring(str)
|
||||
Executes the lua code inside `str`.
|
||||
```lua
|
||||
|
7
lume.lua
7
lume.lua
@ -223,6 +223,13 @@ function lume.format(str, vars)
|
||||
end
|
||||
|
||||
|
||||
function lume.trace(...)
|
||||
local info = debug.getinfo(2, "Sl")
|
||||
local head = "[" .. info.short_src .. ":" .. info.currentline .. "] "
|
||||
print(head .. table.concat(lume.map({...}, tostring), " "))
|
||||
end
|
||||
|
||||
|
||||
function lume.dostring(str)
|
||||
return assert(loadstring(str))()
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user