Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging and debugging tools in Elixir?

Tags:

elixir

I've just started using Elixir, and have started a Phoenix project, which I enjoy a lot. Now by having rails background, I'm used to being spoiled with debugging tools like "debugger", "byebug" and so on; I was wondering if there are any similar tools for Elixir? How are you guys debugging your Elixir applications?

Even an equivalent to Rubys raise my_object.inspect, would do wonders!

Thank you

like image 223
MartinElvar Avatar asked Feb 25 '15 16:02

MartinElvar


People also ask

What are debugging tools in Visual Basic?

Debugging tools are designed to help with: Stopping the execution of a program at specific points. Detecting run-time and logic errors. Understanding the behaviour of error-free code.

How do I debug in Phoenix?

Set up the debuggerWhen you open a phoenix or elixir project in Visual Studio Code, you should have a Run and Debugger option in your menu. If you don't see it, you can run a Show Run and Debug command with ctrl-shift-D . If you want to run the example code for yourself, then you can clone the example repository.


1 Answers

You can use IEx

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

If you start this program with for example iex -s program.exs (or iex -S mix for a project) you'll be asked if you want to allow prying into this code when it is reached and value will be available for you for inspection.

You can also just do print debugging using IO.inspect allowing you to output basically any erlang data structure.

like image 68
Paweł Obrok Avatar answered Sep 17 '22 13:09

Paweł Obrok