rb:list()
またはを使用して sasl ログでメッセージを検索するrb:show()
と、rb は出力をコンソールにダンプし、「ok」を返すようです。実際のログメッセージを返すように rb を設定する方法はありますか?
ありがとう
rb:list()
またはを使用して sasl ログでメッセージを検索するrb:show()
と、rb は出力をコンソールにダンプし、「ok」を返すようです。実際のログメッセージを返すように rb を設定する方法はありますか?
ありがとう
ログを一時ファイルにダンプし、そのファイルを読み取る次の関数を使用しています。
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.