在管道中除錯
defmodule Demo do
def foo do
1..10
|> Enum.map(&(&1 * &1)) |> p
|> Enum.filter(&rem(&1, 2) == 0) |> p
|> Enum.take(3) |> p
end
defp p(e) do
require Logger
Logger.debug inspect e, limit: :infinity
e
end
end
iex(1)> Demo.foo
23:23:55.171 [debug] [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
23:23:55.171 [debug] [4, 16, 36, 64, 100]
23:23:55.171 [debug] [4, 16, 36]
[4, 16, 36]