Debugging and debugging tools in Elixir?

I just started using Elixir and started the Phoenix project, which I really like. Now that I have a rail background, I’m used to getting rid of debugging tools such as "debugger", "byebug", etc .; I was wondering if there are similar tools for Elixir? How do you guys debug your Elixir apps?

Even the equivalent of Rubys raise my_object.inspect would do wonders!

thank

+53
elixir
Feb 25 '15 at 16:30
source share
4 answers

You can use IEx

 require IEx value = {:some, :erlang, :value} IEx.pry 

If you run this program, for example, iex -s program.exs (or iex -S mix for a project), you will be asked if you want to allow this code when it is reached, and value will be available for you to check.

You can also simply debug fingerprints using IO.inspect , allowing you to display basically any erlang data structure.

+62
Feb 25 '15 at 17:19
source share

Debugging Cowboy applications and Phoenix applications.

I saw this post on Elixir rader http://www.jessetrimble.net/iex-pry-elixir , and thought I would just let it down here, as it is extremely convenient :-).

In Rails (and others) applications, you can simply put the debug tag in your controller, and when the path is launched, it will be split into a debug tag.

When using pry in Phoenix, the above will result in

 Cannot pry #PID<0.259.0> at web/controllers/posts_controller.ex:8. Is an IEx shell running? 

It turns out that the Phoenix process should be running in an IEx session, this is done as such

 iex -S mix phoenix.server 

Now instead you will see

 Request to pry #PID<0.266.0> at web/controllers/posts_controller.ex:9. Allow? [Yn] 
+29
Jun 29 '15 at 8:00
source share

You can use the Quaff.Debug module from https://github.com/qhool/quaff

The Debug module provides a simple helper interface for running Elixir code in erlang graphical debugging

I tested it today with Elixir 1.0.4, it works.

+10
May 17 '15 at 9:06
source share

Use the Erlang debugger. Example with Phoenix 1.3 and Elixir 1.5.1, source file: ./ lib / todo / api / api.ex and module name: Todo.API

 ~/elixir/todo_app/ iex -S mix phx.server Erlang/OTP 20 [erts-9.0] [source] [smp:1:1] [ds:1:1:10] [async-threads:10] [hipe] [kernel-poll:false] [info] Running TodoWeb.Endpoint with Cowboy using http://0.0.0.0:4000 Interactive Elixir (1.5.1) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> :debugger.start() {:ok, #PID<0.373.0>} iex(2)> :int.ni(Todo.API) {:module, Todo.API} 

In the Erlang debugger:

  • The left panel in the Monitor window shows the loaded module.
  • In the "Module" menu, the loaded module with the "View" and "Delete" submenus is displayed below. Use the View menu to see the source with line numbers.
  • To place a breakpoint, use the Break menu, Line Breaks ...
  • Run the program until it stops at the specified line. Monitor windows show a process with a status of "break". Double-click this line to open the connected process in the debugger. Here you can step, move (further), continue, climb, check values, etc. To enter another module, it must also be loaded, as described above.
  • The breakpoint will be ignored if it is not placed correctly. If you have a multi-line pipeline, place a breakpoint on the last line.
0
Dec 18 '17 at
source share



All Articles