Closed sousoux closed 9 years ago
Good idea. A hacky way is to replace require('pretty-print').stdout
, then require log, then replace stdout with the original value.
do
local pp = require('pretty-print')
local stdout = pp.stdout
local out = {}
function out:write(...)
-- Custom output
end
pp.stdout = out
-- This has to be the first ever require to log, so do this before loading lit.
require('lit/libs/log')
pp.stdout = stdout
end
It's hacky, I'll see about making an official API for it.
Ok, the interface to log changed a little. To set a custom stream for the logger to write to do:
local out = {}
function out:write(...)
-- custom output
end
require('lit/libs/log').stream = out
This can happen at any time before or after the first require to log happens.
Many thanks
Lit currently picks up its log function from ./log which makes if difficult to redirect without a custom package. Would be good if you could pass a log function to core in the config table.