-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
log.lua
41 lines (30 loc) · 820 Bytes
/
log.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local topoRuntime = require(script.Parent.Parent.topoRuntime)
local format = require(script.Parent.Parent.debugger.formatTable)
--[=[
@within Matter
:::info Topologically-aware function
This function is only usable if called within the context of [`Loop:begin`](/api/Loop#begin).
:::
@param ... any
Logs some text. Readable in the Matter debugger.
]=]
local function log(...)
local state = topoRuntime.useFrameState()
if state.logs == nil then
return
end
local segments = {}
for i = 1, select("#", ...) do
local value = select(i, ...)
if type(value) == "table" then
segments[i] = format.formatTable(value)
else
segments[i] = tostring(value)
end
end
table.insert(state.logs, table.concat(segments, " "))
if #state.logs > 100 then
table.remove(state.logs, 1)
end
end
return log