pfitz
What are your debugging techniques?
Coming from Objective-C/Swift/PHP/Java I am used to a full IDE for my projects. The one thing I miss the most is a good debugger. So far I just did „poor mans debugging“ with IO.inspect but I am guessing there are better ways to debug ones elixir apps. So how do you debug your apps ?
Most Liked
rvirding
You have to be very careful when debugging things in a concurrent environment, at least when you debug in a more traditional way which stops and controls execution. Anything that is waiting for the debugged process will hang and in many cases may time out and crash, which is not what was intended. Also doing something like IEx.pry in a function which is called in many processes will also be interesting.
Sorry to sound very negative here but having very concurrent systems does change you need to work with them. Sometimes IO.inspect is all that is reasonable. Or use the built-in tracing facilities.
Robert
Qqwy
Because of the ability to run multiple Erlang applications side-by-side in the same process and because of metaprogramming awesomeness, one of the fancy things you can do is IEX.pry(after you require IEx in the module) , which starts a shell at that current location in the code, so you can debug the scope you are in.
The cool thing about IO.inspect by the way is that you can plug it in everywhere in your pipelines without altering the result:
(1..10)
|> IO.inspect
|> Enum.map(fn x -> x * x end)
|> IO.inspect
|> Enum.sum
|> IO.inspect
gausby
I think that we, as a community, need to study our options for inspecting our applications. As others has mentioned in this thread: The Beam is a different beast. Introducing break points changes the program and such.
Personally I have to look into this book: http://www.erlang-in-anger.com. It is another Erlang book, but learning a little bit of Erlang goes a long way :)—it describes strategies for tracing and probing a running Erlang system.
Last Post!
stephen_m
(1..10)
|> IO.inspect
|> Enum.map(fn x -> x * x end)
|> IO.inspect
|> Enum.sum
|> IO.inspect
As above, I do very similar to Qqwy except I log the result. often times with pieces of data from the ENV macro.
Except I use Og, a tiny set of functions that log it instead,
(1..10)
|> Og.log_return() # defaults to debug
|> Enum.map(fn x -> x * x end)
|> Og.log_return(__ENV__, :info) # will print line, number func and in `info` style
|> Enum.sum
|> Og.log_return(__ENV__, :debug)
I end up using __ENV__ alot.
Not sure if this is good or not though but it’s helped me. ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









