tags:

views:

149

answers:

2

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

A: 

It seems to be the same issue as this one or this one

probsolver
I read through the solution to the first link. Forgive me - I have limited experience of Erlang - but I can't see how the act of finding a process' group leader helps with getting log messages out of rb. Whose group leader do I need to find ? [rb's ? the current process ?] Assuming I have a group leader, how do I pass it to rb ? [can't see any rb function that would accept group leader as an arg]. Any help would be much appreciated. Thank you.
Justin
It is not the question that is relevant, it is the answer :)Erlang 'io' module uses io server processes, which is by default group leader processes.http://erlang.org/doc/apps/stdlib/io_protocol.htmlrb uses io:format calls for it's output. So you have 2 choices:
probsolver
First is to used modified rb which allows to set output device (another name for io server process), and i suspect, that modification could only touch rb:open_log_file/1 function for the most hackish solution.In this case you'll have to find local shell group leader with erlang:group_leader() to send rb output there.Second is to start your node with (standard) wrapper and see it's sdtout with to_erl.
probsolver
A: 

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.
legoscia