【发布时间】:2016-01-02 10:55:39
【问题描述】:
我尝试了以下
def index(conn, _params) do
Logger.debug conn
......
但我明白了
protocol String.Chars not implemented for %Plug.Conn
我什至尝试过 Apex,但也没有用。
【问题讨论】:
我尝试了以下
def index(conn, _params) do
Logger.debug conn
......
但我明白了
protocol String.Chars not implemented for %Plug.Conn
我什至尝试过 Apex,但也没有用。
【问题讨论】:
您应该可以使用Kernel.inspect/2 漂亮地打印conn:
Logger.debug inspect(conn)
【讨论】:
使用inspect conn, pretty: true
... 或:
inspect conn, pretty: true, limit: 30000
...因为Conn 结构非常大。
【讨论】:
limit: :infinity。
IO.inspect 很好。我在我的副项目中使用过,比如 ruby awsome_print
【讨论】:
您确实可以使用Kernel.inspect/2 漂亮地打印%Plug.Conn{} 的内容,使用:
def index(conn, _params) do
:logger.info inspect(conn, pretty: true)
....
end
请注意,以前使用Logger 的答案应该提到您需要在使用它之前require Logger,如:
require Logger
def index(conn, _params) do
Logger.info inspect(conn, pretty: true)
....
end
【讨论】: