IO.inspect supports a label option.

October 16, 2020

Sometimes when you're using IO.inspect/2 to debug values, your output can be a bit overwhelming. To make things easier to read, you can pass IO.inspect/2 a label option.

Before

Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> example = %{foo: "bar"}
%{foo: "bar"}
iex(2)> IO.inspect(example)
%{foo: "bar"}
%{foo: "bar"}

After

Interactive Elixir (1.10.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> example = %{foo: "bar"}
%{foo: "bar"}
iex(2)> IO.inspect(example, label: "BAZ")
BAZ: %{foo: "bar"}
%{foo: "bar"}

Sources

  1. hexdocs

© 2024, Built with ❤️ by Blake Dietz