I use IO.inspect/2
all the time
when I'm debugging something, and I often run into a problem where I'm looking
at a gigantic map with lots of fields that gets truncated. I usually want
everything to be printed, and I have to remember the options to enable it. So
for reference for my future self, here's a handy function that actually prints
everything:
def io_inspect(item, opts \\ []) do
opts =
opts
|> Keyword.put(:limit, :infinity)
|> Keyword.put(:printable_limit, :infinity)
|> Keyword.put(:width, 0)
IO.inspect(item, opts)
end
I kinda wish the default was to print everything, with options to truncate if desired. The power of defaults...
You can also customize the default behavior of IO.inspect/2
inside of IEx by
putting the following in ~/.iex.exs
:
IEx.configure(
inspect: [limit: :infinity, printable_limit: :infinity, width: 0]
)