Skip to content

Commit

Permalink
Optimize (not) printing empty string from formatter
Browse files Browse the repository at this point in the history
Sometimes it is handy to implement some additional filtering in a
custom formatter function. In this case the formatter can return the
empty string if it wants to ignore a trace message. Optimize the
formatting so in the empty string case it does not send an io request
to the IO server. This avoids a "flickering prompt" effect (when the
empty string is printed) in case of 1000s of ignored trace messages
per second.
  • Loading branch information
gomoripeti committed Oct 8, 2024
1 parent c2a7685 commit c76b423
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/recon_trace.erl
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ formatter(Tracer, IOServer, FormatterFun) ->
{'EXIT', Tracer, Reason} ->
exit(Reason);
TraceMsg ->
io:format(IOServer, FormatterFun(TraceMsg), []),
case FormatterFun(TraceMsg) of
"" -> ok;
Formatted -> io:format(IOServer, Formatted, [])
end,
formatter(Tracer, IOServer, FormatterFun)
end.

Expand Down

0 comments on commit c76b423

Please sign in to comment.