154
154
% %% so tracing is automatically turned off once you disconnect.
155
155
% %%
156
156
% %% If sending output to the Group Leader is not desired, you may specify
157
- % %% a different pid() via the option `output ' in the {@link calls/3} function.
157
+ % %% a different pid() via the option `io_server ' in the {@link calls/3} function.
158
158
% %% For instance to write the traces to a file you can do something like
159
159
% %%
160
160
% %% 1> {ok, Dev} = file:open("/tmp/trace",[write]).
161
- % %% 2> recon_trace:calls({queue, in, fun(_) -> return_trace() end}, 3, [{output , Dev}]).
161
+ % %% 2> recon_trace:calls({queue, in, fun(_) -> return_trace() end}, 3, [{io_server , Dev}]).
162
162
% %% 1
163
163
% %% 3>
164
164
% %% Recon tracer rate limit tripped.
165
165
% %% 4> file:close(Dev).
166
166
% %%
167
167
% %% The only output still sent to the Group Leader is the rate limit being
168
- % %% tripped, and any errors.
168
+ % %% tripped, and any errors. The rest will be sent to the other IO
169
+ % %% server (see [http://erlang.org/doc/apps/stdlib/io_protocol.html]).
169
170
% %% @end
170
171
-module (recon_trace ).
171
172
191
192
| {args , args | arity } % default: args
192
193
% % match pattern options
193
194
| {scope , global | local } % default: global
194
- | {output , pid ()} % default: group_leader()
195
+ | {io_server , pid ()} % default: group_leader()
195
196
].
196
197
197
198
-type mod () :: '_' | module ().
@@ -366,16 +367,16 @@ formatter(Tracer, Parent, Ref, FormatterFun, IOServer) ->
366
367
Parent ! {Ref , linked },
367
368
formatter (Tracer , IOServer , FormatterFun ).
368
369
369
- formatter (Tracer , Leader , FormatterFun ) ->
370
+ formatter (Tracer , IOServer , FormatterFun ) ->
370
371
receive
371
372
{'EXIT' , Tracer , normal } ->
372
373
io :format (" Recon tracer rate limit tripped.~n " ),
373
374
exit (normal );
374
375
{'EXIT' , Tracer , Reason } ->
375
376
exit (Reason );
376
377
TraceMsg ->
377
- io :format (Leader , FormatterFun (TraceMsg ), []),
378
- formatter (Tracer , Leader , FormatterFun )
378
+ io :format (IOServer , FormatterFun (TraceMsg ), []),
379
+ formatter (Tracer , IOServer , FormatterFun )
379
380
end .
380
381
381
382
@@ -385,12 +386,12 @@ formatter(Tracer, Leader, FormatterFun) ->
385
386
386
387
% % starts the tracer and formatter processes, and
387
388
% % cleans them up before each call.
388
- setup (TracerFun , TracerArgs , FormatterFun , OutputTo ) ->
389
+ setup (TracerFun , TracerArgs , FormatterFun , IOServer ) ->
389
390
clear (),
390
391
Ref = make_ref (),
391
392
Tracer = spawn_link (? MODULE , TracerFun , TracerArgs ),
392
393
register (recon_trace_tracer , Tracer ),
393
- Format = spawn (? MODULE , formatter , [Tracer , self (), Ref , FormatterFun , OutputTo ]),
394
+ Format = spawn (? MODULE , formatter , [Tracer , self (), Ref , FormatterFun , IOServer ]),
394
395
register (recon_trace_formatter , Format ),
395
396
receive
396
397
{Ref , linked } -> Tracer
0 commit comments