get rid of to_text
[lines.love.git] / log.lua
blob6bbd0c4bd4160f5ab7137923cecaf93985f988ca
1 function log(stack_frame_index, obj)
2 local info = debug.getinfo(stack_frame_index, 'Sl')
3 local msg
4 if type(obj) == 'string' then
5 msg = obj
6 else
7 msg = json.encode(obj)
8 end
9 love.filesystem.append('log', info.short_src..':'..info.currentline..': '..msg..'\n')
10 end
12 -- for section delimiters we'll use specific Unicode box characters
13 function log_start(name, stack_frame_index)
14 if stack_frame_index == nil then
15 stack_frame_index = 3
16 end
17 log(stack_frame_index, '\u{250c} ' .. name)
18 end
19 function log_end(name, stack_frame_index)
20 if stack_frame_index == nil then
21 stack_frame_index = 3
22 end
23 log(stack_frame_index, '\u{2518} ' .. name)
24 end
26 function log_new(name, stack_frame_index)
27 if stack_frame_index == nil then
28 stack_frame_index = 4
29 end
30 log_end(name, stack_frame_index)
31 log_start(name, stack_frame_index)
32 end
34 -- rendering graphical objects within sections/boxes
35 log_render = {}
37 -- vim:noexpandtab