Walid-Shouman
10/24/2016 - 3:24 PM

a guide for moving around into an elixir project

a guide for moving around into an elixir project

Configurations

  • Configurations files structure and navigating them: Github guide
  • Generally:
config/
├── config.exs
├── dev.exs
├── prod.exs
└── test.exs

Logging

require Logger
Logger.debug "This is a debug line."
  • Print variable content
inspect(a)
  • Print type and useful info to screen: SO answer
i some_variable

i is defined as a protocol, it's implementation was useful

Logging Notes

  • Following will work as long as struct_variable isn't a structure
Logger.debug non_struct_variable

Struct variables will produce the following error protocol String.Chars not implemented for, avoid that by using

Logger.debug inspect(struct_variable)

Debugging

  • Debug elixir code using:
require IEx
IEx.pry

A useful Debug guide for elixir: Blog article

  • Debugging Phoenix is a bit tricky, we need to execute phoenix itself From inside an interactive shell ie:
iex -S mix phoenix.server

Ref. blog article