When looking up messages in a sasl log using rb:list()
or rb:show()
, rb seems to dump the output in the console and return 'ok'; is there any way to configure rb to get it to return the actual log message ?
Thanks
When looking up messages in a sasl log using rb:list()
or rb:show()
, rb seems to dump the output in the console and return 'ok'; is there any way to configure rb to get it to return the actual log message ?
Thanks
I've been using the following function, which dumps the logs to a temporary file and reads that file:
get_logs(LogDir) ->
TmpFile = lists:flatten(io_lib:format("log_tmp_~B_~B_~B", tuple_to_list(now()))),
try
% Make the report browser write logs to a temporary file.
% We use rb:start_link instead of rb:start, to not depend on the sasl
% application being started.
{ok, _} = rb:start_link([{start_log, TmpFile},
{report_dir, LogDir}]),
rb:show(),
% We catch errors from stopping, since we're going to get one
% if sasl isn't started. (UTSL)
catch rb:stop(),
% Ouch... let's hope the logs fit in memory.
case file:read_file(TmpFile) of
{ok, Logs} ->
Logs;
{error, Error} ->
io_lib:format("Couldn't read logs: ~p", [Error])
end
catch _:E ->
io_lib:format("Couldn't read logs: ~p", [E])
after
file:delete(TmpFile)
end.