How to Log something in Controller when Phoenix Server is running?

Okay, turns out it’s pretty straight forward. You need to require the Logger elixir module in your controller and call one of it’s methods to log your text. defmodule PhoenixApp.TopicController do require Logger def index(conn, params) do Logger.info “Logging this text!” Logger.debug “Var value: #{inspect(params)}” # … end end Supported levels are: :debug – for … Read more

Debugging and debugging tools in Elixir?

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. … Read more

Elixir Sleep / Wait for 1 Second

Timer uses milliseconds not seconds, update to: IO.puts “foo” ; :timer.sleep(1000); IO.puts “bar” Documentation of :timer in Erlang’s doc: Suspends the process calling this function for Time amount of milliseconds and then returns ok, or suspend the process forever if Time is the atom infinity. Naturally, this function does not return immediately. http://erlang.org/doc/man/timer.html#sleep-1

What’s the difference between `def` and `defp`

From Elixir’s documentation on functions within modules: Inside a module, we can define functions with def/2 and private functions with defp/2. A function defined with def/2 can be invoked from other modules while a private function can only be invoked locally. So defp defines a private function.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)