[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: stdout to buffer
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 15 Jul 2013 13:45:33 -0300
> I'd like to accumulate stdio to a buffer.
The easiest way is to redefined the functions that write to stdout.
For instance, like this (untested):
local buffer={}
local bufsiz=0
function print(...)
local t=table.pack{...}
for i=1,t.n do t[i]=tostring(t[i]) end
bufsiz=bufsiz+1
buffer[bufsiz]=table.concat(t,"\t",1,n)
end
At the end, send table.concat(buffer,"\n") back to the client.