Approach to development in Elixir - Utilising Elixir tools better

This is a general discussion for how to use Elixir tooling better for development. (OTP or Phoenix projects)

Currently, I and my friend use IO.inspect everywhere in our app to debug what is not working.
We have a nice ColorIO module which enables us to IO.inspect in different colors. :stuck_out_tongue:

This is one approach to development we learnt while being in JS and Python ecosystem. Just log everything to terminal.

  1. What are other ways people develop / debug their apps?
  2. Are there some good Elixir tools for debugging?
  3. Any other questions that people want to discuss, I will put them here after editing.


(since Elixir 1.13 mentions a lot of tooling and behind the scenes changes, I wonder if I am yet unaware of some awesome tool.)

1 Like

Sometimes tracing is more informative than manual IO.inspect

In tests I start tracing before the failing function is called:

test "some curious failure" do
  Rexbug.start("Schrodingbug :: return", msgs: 30)
  refute Schrodingbug.maybe_fail()

In dev I can run it before execution some function in UI / API request, like before logging in:

iex> Rexbug.start("Accounts :: return", msgs: 100, time: 10000)

# ... starts printing out traces of the function executed in the login flow
# ... gives a better understanding of how things fit together

Best of all it works in prod, but that use-case is already described in the project descriptions above.


Will check it out and let you know!

Seems powerful.

It is. If you look into tracing, give the Rexbug print_fun option a try: print_fun

Custom function to use to print the trace messages.

So you have full control. You could eg color the trace for starters.